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 );
}