ListViewItem Collection EditorListViewItem Collection Editor

Rabu, 30 Juni 2010

ListViewItem Collection Editor



When you select the first item on the ListView Tasks menu, the ListViewItem Collection Editor is displayed. This editor can also be accessed by clicking on the button in the right hand column of the Items property in the Properties Window.


Once the editor is open, ListViewItems can be added or removed, and their properties can be set. A ListViewItem object can display an image along with text. An ImageList must be used to associate an image with a ListViewItem object.
The ListViewItem class represents items in a ListView control and the ListViewSubItem class represents a sub-item related to a ListViewItem. The ListViewItem class exposes the SubItems collection property that represents the list of sub-items related to an item. The number of sub-items should equal the number of columns minus one.
This editor can also be accessed by clicking on the button in the right hand column of the SubItems property in the ListViewItem Collection Editor.

Adding items manually
Items can be added manually by adding ListViewItems to the ListView's Items collection property. The following code demonstrates how to add items to a ListView control:


ListViewItem listViewItem1 = new ListViewItem();
ListViewSubItem listViewSubItem1 = new ListViewSubItem();

listViewItem1.Text = "Joe";
listViewSubItem1.Text = "123 Somewhere Street";

listViewItem1.SubItems.Add(listViewSubItem1);
listView1.Items.Add(listViewItem1);



source : http://en.csharp-online.net/ListView

Tidak ada komentar:

Posting Komentar