Edit this page

Unbound Mode

When in unbound mode, RadListView doesn't use a data source to generate its content. In this mode, you need to add items either at design time, or at run time.

Adding Items at Design Time

Adding items to RadListView at design time is possible through the Items collection of the control. This collection is accessible by using the Smart Tag or the Items collection property in the property grid. Further information is available in the Adding Items help article.

Adding Items at Run Time

The items in RadListView are stored in a collection that is accessible through the Items property. Items 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

When in DetailsView, RadListView displays columns. The columns 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"))

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"

important

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.

It is possible to add columns at design time as well by either using the Smart Tag or the Columns collection in the Properties section in Visual Studio. Further information is available in the Adding Columns help article.

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.

It is possible to add groups at design time as well by either using the Smart Tag or the Groups collection in the Properties section in Visual Studio. Further information is available in the Adding Groups help article.

See Also