读书人

怎么道鼠标悬停在ListBox的那个item上

发布时间: 2012-01-08 22:48:50 作者: rapoo

如何道鼠标悬停在ListBox的那个item上面了?
ListBox已经绑定了数据,鼠标停在上面的时候,我有什么办法知道停在哪一条数据上面呢?

[解决办法]
private void listBox1_MouseMove(object sender, MouseEventArgs e)
{
int AIndex = ((ListBox)sender).IndexFromPoint(e.Location);
if (AIndex < 0) return;
Text = ((ListBox)sender).Items[AIndex].ToString();
}

读书人网 >C#

热点推荐