$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
ListView WinForms Control
Create functional user interfaces, display data, group, filter, sort, and customize data items
Home > WinForms UI Controls > User Manual > Add Groups in ListView in C#

Add Groups to ListView in C# at Design Time

The ListView Controls for Windows Forms provide design-time support functionality to developers. This feature allows developers easily choose a data source or populate it with unbound items, groups and columns when design the user interface for their Windows Form applications. The users can easily add columns to ListView, group items in ListView, and add items to ListView at design time in C#.NET templates

How to Group Items in ListView at Design Time

The Kettic ListView control provides enhanced grouping functionality for the users. It helps the users to group data items into different groups conveniently and offers excellent end-user experience. Moreover, the ListView control is capable of grouping items at design time. To accomplish the ListView items grouping, we need to enable the properties of the ListView control, EnableCustomGroups and DisplayGroups, and then add the desired groups into the Groups collection of Kettic ListView Control. The following steps shows how to add groups to ListView control
  1. First, we need to access the Groups collection of Kettic ListView Control through the Groups property in the property of the component or the Smart Tag of the of Kettic ListView WinForms control.
  2. When opening the ListViewDataItemGroup collection, we can add the desired groups to the collection by using the Add button at the bottom
  3. To modify the group settings, we can customize the properties in the property grid
  4. After adding the desired groups, we can set the ListViewDataItem.Group property to assign each ListViewDataItem to the group that we selected.
  5. Run the applications, you will see the grouped items in list view.

Customize ListView Grouping in C#.NET

The following is a sample that demonstrates how to customize the grouping functionality in C# code. To accomplish this, we need to subscribe to the ChangedSelectedIndex event of commandBarDropDownGroup and add the desired GroupDescriptors from the selected item in the drop down. The C# code shows how to handle the group functionality event

private void commandBarDropDownGroup_ ChangedSelectedIndex(object sender, Kettic.WinForms.UI.Data.PositionChangedEventArgs e)
{
this.ketticListView1.GroupDescriptors.Clear();
switch (this.commandBarDropDownGroup.Text)
{
case "None":
this.ketticListView1.EnableGrouping = false;
this.ketticListView1.DisplayGroups = false;
break;
case "Category":
this.ketticListView1.GroupDescriptors.Add(new GroupDescriptor(
new SortDescriptor[] { new SortDescriptor("CategoryName", ListSortDirection.Ascending) }));
this.ketticListView1.EnableGrouping = true;
this.ketticListView1.DisplayGroups = true;
break;
case "Price":
this.ketticListView1.GroupDescriptors.Add(new GroupDescriptor(
new SortDescriptor[] { new SortDescriptor("ProductName", ListSortDirection.Descending) }));
this.ketticListView1.EnableGrouping = true;
this.ketticListView1.DisplayGroups = true;
break;
}
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls