Use of listview in Windows Forms

Source: Internet
Author: User
Reproduced from: http://student.csdn.net/space.php? Uid = 113202 & Do = Blog & id = 39978c # How to obtain the selected listview reward score: 30-solution time:
RT: there are nine items in listview. If you click any item, How can I obtain it? Try to be specific ~ Thank you ~
Best Answer
Text Value of the selected item: This. listview1.selecteditems [0]. text; the text value of the selected subitem this. listview1.selecteditems [0]. subitems [0]. text; (subitems [0] indicates the first subitem of the selected item, the second subitem is subitem [1], and the third is subitems [2] ..
... And so on)

Example code of listview usage

 This. listview1.view = view. details;
Listview listview1 = new listview ();

// Set the view to show details.
Listview1.view = view. details;
// Allow the user to edit item text.
Listview1.labeledit = true;
// Allow the user to rearrange columns.
Listview1.allowcolumnreorder = true;

// Display check boxes. Whether to display the check box
Listview1.checkboxes = true;
// Select the item and subitems when selection is made. Check whether the entire row is selected.
Listview1.fullrowselect = true;
// Display grid lines. Whether to display the grid
Listview1.gridlines = true;
// Sort the items in the list in ascending order. ascending or descending
Listview1.sorting = sortorder. ascending;
This. listview1.columns. Add ("no.", 60, horizontalalignment. Right );
This. listview1.columns. Add ("name", 60, horizontalalignment. Right );
This. listview1.columns. Add ("Age", 60, horizontalalignment. Right );
This. listview1.columns. Add ("phone", 60, horizontalalignment. Right );
This. listview1.visible = true;

For (INT I = 20; I> = 1; I --)
{
Listviewitem li = new listviewitem ();
Li. subitems [0]. Text = I. tostring ();
Li. subitems. Add ("AAA ");
Li. subitems. Add ("25 ");
Li. subitems. Add ("11223344 ");
This. listview1.items. Add (LI );
}

 

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.