C# listview鼠标移动颜色设置问题

private void Listview1_MouseMove(object sender, MouseEventArgs e)
{
ListView _ListView = (ListView)sender;
ListViewItem _OldItem = null;
if (_ListView.Tag != null) _OldItem = (ListViewItem)_ListView.Tag;

ListViewItem _Item = _ListView.GetItemAt(e.X, e.Y);
if (_Item != null)
{
if (_OldItem != null && !_OldItem.Equals(_Item)) _OldItem.BackColor = _ListView.BackColor;
_Item.BackColor = Color.Red;
_ListView.Tag = _Item;
}
else
{
if (_OldItem != null && !_OldItem.BackColor.Equals(_ListView.BackColor)) _OldItem.BackColor = _ListView.BackColor;
}
}

posted @ 2017-01-11 16:42  FelixWang  阅读(1127)  评论(0编辑  收藏  举报