Edit this page

Programmatically populating with data

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.

Adding items

this.radListView1.Items.Add(new ListViewDataItem("Item 1"));
this.radListView1.Items.Add("Item 2");

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.

Adding columns

this.radListView1.Columns.Add("Column1");
this.radListView1.Columns.Add("Column2", "Column2Header");
this.radListView1.Columns.Add(new ListViewDetailColumn("Column3", "Column3Header"));

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.

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";

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.

Adding groups

this.radListView1.Groups.Add(new ListViewDataItemGroup("First Group"));
this.radListView1.Groups.Add(new ListViewDataItemGroup("Second Group"));

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:

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];

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: