How do I show a rectangle around listviewItem when I hover the mouse over it like in the video? I use mousehover / mousemove event. I need a sample code (C# - WinForm) that can do that. Sorry I use google translate
my listview item have image and text. How to show image and text in DrawItem private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e) { Color textColor = SystemColors.WindowText; if (e.Item.Selected) { if (listView1.Focused) { textColor = SystemColors.HighlightText; e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds); } else if (!listView1.HideSelection) { textColor = SystemColors.ControlText; e.Graphics.FillRectangle(SystemBrushes.Control, e.Bounds); } } else { using (SolidBrush br = new SolidBrush(listView1.BackColor)) { e.Graphics.FillRectangle(br, e.Bounds); } } e.Graphics.DrawRectangle(Pens.Red, e.Bounds); TextRenderer.DrawText(e.Graphics, e.Item.Text, listView1.Font, e.Bounds, textColor, Color.Empty, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); }
ListViewHitTestInfo hti = listView1.HitTest(e.X, e.Y); //where e is System.Windows.Forms.MouseEventArgs if(hti.Item == null) return; //get index of subitem: var subid = hti.Item.SubItems.IndexOf(ht.SubItem); //further instructions here....
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)