$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 > ListView Grouping in C#

Grouping in ListView for C# Windows Forms

Kettic ListView WinForms Control provides the support of grouping items in ListView for C#.NET Windows Forms applications. It allows the users to create automatic grouping and custom grouping according to a certain property. Furthermore, the grouping functionality can be performed in all views in ListView control. The grouping mechanism for ListView makes it easy to use the component for .NET project being deployed on other C#.NET applications. It is really easy to perform the grouping operations on the fly when the users exposed event for grouping items.

How to Enable Grouping for ListView in C#

Kettic ListView .NET component allows the users to create automatic grouping and custom grouping according to a certain property. To create automatic grouping for ListView in C#.NET, the users need to first enable the properties, EnableGrouping and DisplayGroups and then add the desired GroupDescriptors to the GroupDescriptors collection of the ListView component. The following C# code demonstrates how to group items according to various properties.

How to Group ListView Items by Value in C#.NET

C# code for grouping items in ListView by value property

ketticListView1.EnableGrouping = true;
ketticListView1.DsiplayGroups = true;
GroupDescriptor groupByValue = new GroupDescriptor(new SortDescriptor[] { new SortDescriptor("Value", ListSortDirection.Ascending) });
ketticListView1.GroupDescriptors.Add(groupByValue);

How to Group ListView Items by Value in C#.NET

The following C# code shows how to group items by a specific column in ListView control. In the example, we will use the DetailsView property.

ketticListView1.EnableGrouping = true;
ketticListView1.DisplayGroups = true;
GroupDescriptor groupByType = new GroupDescriptor(new SortDescriptor[]
{
new SortDescriptor("Type", ListSortDirection.Descending),
});
ketticListView1.GroupDescriptors.Add(groupByType);

How to Group ListView Items by Value in C#.NET

The KetticListView control provides the support of creating custom grouping feature based on a specific property. This is accomplished by busing the EnableCustomGrouping property and adding the desired descriptor. The C# code below demonstrates how to perform the custom grouping in ListView control.

ketticListView1.EnableCustomGrouping = true;
ketticListView1.DisplayGroups = true;
ListViewDataItemGroup proGroup = new ListViewDataItemGroup("Products");
ListViewDataItemGroup priceGroup = new ListViewDataItemGroup("Price");
ketticListView1.Groups.Add(proGroup);
ketticListView1.Groups.Add(priceGroup);
foreach (ListViewDataItem item in ketticListView1.Items)
{
if (item.Value.ToString() == "Products" || item.Value.ToString() == "Promote Products")
{
item.Group = productsGroup;
}
else
{
item.Group = priceGroup;
}
}

How to Group Bound Items in ListView in C#.NET

When the users bind the ListView to a data source, and need to group the items, they can use the ItemDataBound event to achieve this. After firing the ItemDataBound event, they need to assign certain items from the data to a certain group. Then the grouping data items in ListView can be done.
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