日期:2014-05-17  浏览次数:21233 次

如何实现 C# winform ListView 鼠标移入行时,行变色高亮
如何实现 C# winform ListView 鼠标移入行时,行变色高亮,

------解决方案--------------------

  private ListViewItem prItem;
        private void listView1_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e)
        {
            if (prItem != null)
            {
                prItem.BackColor = Color.White;
            }
            prItem = e.Item;
            e.Item.BackColor = Color.Red;
        }


------解决方案--------------------

        ListViewItem oldSelectedItem = null;
        private void listView1_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e)
        {
            if (oldSelectedItem != null)
            {
                oldSelectedItem.BackColor = Color.White;
            }
            e.Item.BackColor = Color.LightSkyBlue;
            e.Item.ToolTipText = string.Format("点击搜索\"{0}\"的歌曲", e.Item.Text);
            oldSelectedItem = e.Item;
        }