Telerik UI for WinForms

Adding items

The columns of RadListView are stored in a collection that is accessible through the Items property. Columns can be added to RadListView using one of the overloads of the Add method.

Copy[C#] Adding items
this.radListView1.Items.Add(new ListViewDataItem("Item 1"));
this.radListView1.Items.Add("Item 2");
Copy[VB.NET] Adding items
Me.RadListView1.Items.Add(New ListViewDataItem("Item 1"))
Me.RadListView1.Items.Add("Item 2")

Adding columns

The columns of RadListView are stored in a collection that is accessible through the Columns property. Columns can be added to RadListView using one of the three overloads of the Add method as it is shown below. Each column must have unique name because columns are distinguished by their Name property.

Copy[C#] Adding columns
this.radListView1.Columns.Add("Column1");
this.radListView1.Columns.Add("Column2", "Column2Header");
this.radListView1.Columns.Add(new ListViewDetailColumn("Column3", "Column3Header"));
Copy[VB.NET] Adding columns
Me.RadListView1.Columns.Add("Column1")
Me.RadListView1.Columns.Add("Column2", "Column2Header")
Me.RadListView1.Columns.Add(New ListViewDetailColumn("Column3", "Column3Header"))

The columns are visualized when RadListView is in DetailView mode. You can set cell values to the items of RadListView using their indexers. The keys can be either the index of the column, the name of the column, or the column itself.

Copy[C#] Populating cells
ListViewDataItem item = this.radListView1.Items[0];
//it is important that you add the item to the control prior assigning its cell's values, so it will have its cells schema
radListView1.Items.Add(item);

item[0] = "CellValue1";
item["Column2"] = "CellValue2";
item[radListView1.Columns[2]] = "CellValue3";
Copy[VB.NET] Populating cells
Dim item As ListViewDataItem = Me.RadListView1.Items(0)
'it is important that you add the item to the control prior assigning its cell's values, so it will have its cells schema
RadListView1.Items.Add(item)

item(0) = "CellValue1"
item("Column2") = "CellValue2"
item(RadListView1.Columns(2)) = "CellValue3"
Note

To use these indexers the item must have a valid owner e.g. it first has to be added to the Items collection of the RadListView.

Adding Groups

Aside from using GroupDescriptors, custom groups can also be added to RadListView. This is done by using the Add method of the Groups collection of RadListView.

Copy[C#] Adding groups
this.radListView1.Groups.Add(new ListViewDataItemGroup("First Group"));
this.radListView1.Groups.Add(new ListViewDataItemGroup("Second Group"));
Copy[VB.NET] Adding groups
Me.RadListView1.Groups.Add(New ListViewDataItemGroup("First Group"))
Me.RadListView1.Groups.Add(New ListViewDataItemGroup("Second Group"))

In order to assign an item to a group, you should set the item’s Group property:

Copy[C#] Assign item to a group
this.radListView1.Items[0].Group = this.radListView1.Groups[0];
this.radListView1.Items[1].Group = this.radListView1.Groups[0];
this.radListView1.Items[2].Group = this.radListView1.Groups[1];
this.radListView1.Items[3].Group = this.radListView1.Groups[1];
Copy[VB.NET] Assign item to a group
Me.RadListView1.Items(0).Group = Me.RadListView1.Groups(0)
Me.RadListView1.Items(1).Group = Me.RadListView1.Groups(0)
Me.RadListView1.Items(2).Group = Me.RadListView1.Groups(1)
Me.RadListView1.Items(3).Group = Me.RadListView1.Groups(1)

In order to enable this kind of grouping the EnableCustomGrouping property needs to be set to true. In order to display the groups the ShowGroups property needs to be set to true.

You can check which items belong to a given group by iterating trough the Items collection of a ListViewDataItemGroup: