1. Add data and the icon listview1.view = view. details;
Listview1.fullrowselect = true;
// Define the icon file to be used in listview
Imagelist imagelist1 = new imagelist ();
Imagelist1.images. Add (bitmap. fromfile (@ "1.gif "));
Imagelist1.images. Add (bitmap. fromfile (@ "2.gif "));
Imagelist1.images. Add (bitmap. fromfile (@ "3.gif "));
Listview1.smallimagelist = imagelist1; // define the display icon
// Listview1.largeimagelist = imagelist1;
Listviewitem Item1 = new listviewitem ("Item1", 0 );
Item1.subitems. Add ("First Line 1 ");
Item1.subitems. Add ("First Line 2 ");
Item1.subitems. Add ("first line 3 ");
Listviewitem item2 = new listviewitem ("item2", 1 );
Item2.subitems. Add ("First Line 4 ");
Item2.subitems. Add ("first line 5 ");
Item2.subitems. Add ("First Line 6 ");
Listviewitem item3 = new listviewitem ("item3", 2 );
Item3.subitems. Add ("First Line 7 ");
Item3.subitems. Add ("first line 8 ");
Item3.subitems. Add ("first line 9 ");
Listview1.items. addrange (New listviewitem [] {Item1, item2, item3 });
Listview1.columns. Add ("first column ");
Listview1.columns. Add ("second column ");
Listview1.columns. Add ("third column ");
Listview1.columns. Add ("fourth column"); 2. When the cursor is over the row, a prompt different from tooltip is displayed.
// Tooltip controls are used to display the effects of black and yellow characters:
Private void listview1_mousemove (Object sender, mouseeventargs E)
{
Listviewitem item = This. listview1.getitemat (E. X, E. y );
If (item! = NULL)
{
Tooltip1.show (item. Text, listview1, new point (E. x + 15, E. Y + 15), 1000 );
Tooltip1.active = true;
}
Else
{
Tooltip1.active = false;
}
}
// Implement the settooltip method of the tooltip Control for irregular shapes
3. Highlight the mouse over the line
Listviewitem oldselecteditem = NULL;
Private void listviewdomainitemmousehover (Object sender, listviewitemmousehovereventargs E)
{
If (oldselecteditem! = NULL)
{
Oldselecteditem. backcolor = color. White;
}
E. Item. backcolor = color. lightskyblue;
E. Item. tooltiptext = string. Format ("click to search for \" {0} \ "Songs", E. Item. Text );
Oldselecteditem = E. item;
}