Search code examples
c#groupingobjectlistviewcolumnsorting

ObjectListView group by button click


I want to group my ObjectListView but I can only group it when I click on the specific column, but I want to group the list when I click on a button. How can I change that? And I have no event for a column click or something... I´m using this.objectListView1.ShowGroups = true; and I changed the value Groupablein the objectlistview settings to true.

This is how it looks like when I click on the button:

screenshot1

and this is how it looks like when I click on the specific column:

screenshot2

And I don't know why but when I click it also the color of the changes to blue....


Solution

  • I want to group the list when i click on a button.

    objectListView.BuildGroups(myOlvColumn, SortOrder.Ascending);
    

    Where myOlvColumn is the Column you want to create groups for. That should do it.