Usage of listview

Source: Internet
Author: User
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.