C# winform 在listview上用tooltip会闪烁,求解决方案!
private void lvRoomInfo_MouseMove(object sender, MouseEventArgs e)
{
ListViewItem lv = this.lvRoomInfo.GetItemAt(e.X, e.Y);
int x = 0, y = 0;
if (lv != null)
{
//编辑鼠标经过时显示文本
string str = null;
foreach (ListViewItem item in lvRoomInfo.Items)
{
if (item.SubItems[0].Text == lv.Text)
{
str = string.Format("{0}\n{1}\n{2}\n{3}", item.SubItems[0].Text, item.SubItems[1].Text, item.SubItems[3].Text, item.SubItems[5].Text);
}
}
if (x != e.X || y != e.Y) //防止闪烁
{
toolTip.Show(str, lvRoomInfo, e.X, e.Y, 1000);
toolTip.Active = true;
x = e.X;
y = e.Y;
}
else
{
toolTip.Hide(lvRoomInfo);
}
}
}