我的程序员行程

2008-12-2日c#窗体:今天做了很久的鼠标悬浮事件,结果明白应该是移动事件,不过去鼠标坐标的这个用法还将就。


Point position = Point.Empty;


private void lsBFilter_MouseMove(object sender, MouseEventArgs e)
{
position = new Point(e.X, e.Y);
int i = 0;

for (i = lsBFilter.Items.Count - 1; i > 0; i--)
{
if (position.Y >= i * lsBFilter.ItemHeight)
{
lsBFilter.SetSelected(i, true);
break;
}
if (position.Y < lsBFilter.ItemHeight)
{
lsBFilter.SetSelected(0, true);
}

}
}

private void txtBookName_MouseClick(object sender, MouseEventArgs e)
{
lsBFilter.ClearSelected();
lsBFilter.Visible = false;
}


第一次使用文本框和listbox实现方便的数据库查询

private void txtBookName_TextChanged(object sender, EventArgs e)
{
cboBook.SelectedIndex = -1;
cboClass.SelectedIndex = -1;
cboUsers.SelectedIndex = -1;
lsBFilter.Items.Clear();
if (txtBookName.Text.Trim() != "")
{
strSql = string.Format("select DISTINCT Booksname from BookInfo where Booksname like '%{0}%'", txtBookName.Text.Trim());

DBHelper.getDataTableA(strSql);
int i = 0;

while (DBHelper.NumF.Length > 0 && i < DBHelper.NumF.Length)
{
lsBFilter.Items.Add(DBHelper.NumF[i]);
i++;
}
if (DBHelper.NumF.Length > 0)
{
lsBFilter.SetBounds(txtBookName.Location.X, txtBookName.Location.Y + txtBookName.Height, txtBookName.Width, 4 * txtBookName.Height);
lsBFilter.ScrollAlwaysVisible = false;
lsBFilter.Visible = true;
}
lsBFilter.SetSelected(0, true);
}
if (txtBookName.Text.Trim() == "")
{
lsBFilter.Items.Clear();
lsBFilter.Visible = false;
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值