Search code examples
wpfwinformsobjectlistview

How to turn off group by default ?


I use ObjectListView and put it on xaml file. When I click on the column header, it should sort data based on the column. I had added olvServers.Sort(e.Column); when the column click event emits. But it doesn't work.

<!-- declare bis -->
xmlns:bis="clr-namespace:BrightIdeasSoftware;assembly=ObjectListView"

// .... more codes

<!-- about ObjectListView -->
<WindowsFormsHost Grid.Row="1" Margin="0, 3">
  <bis:ObjectListView x:Name="olvServers"
                      AllowColumnReorder="True"
                      ColumnClick="OnOlvServer_ColumnClick"
                      GridLines="True"
                      SelectColumnsOnRightClick="True"
                      SelectColumnsOnRightClickBehaviour="InlineMenu"
                      ShowCommandMenuOnRightClick="True"
                      ShowSortIndicators="True"
                      UseAlternatingBackColors="True"
                      View="Details" />
</WindowsFormsHost>

When I right click on the ObjectListView, and after turn off groups, it works. When clicking on the column header, the data will be sorted by ascending or descending order.

And my question is, how to turn off groups when initialing the ObjectListView object ? I had searched the ObjectListView assembly, and there is no such attribute. So, I don't know how to turn off groups when initialing. Any help will be appreciated.

enter image description here


Solution

  • Change the ShowGroups property of ObjectListView to false, this property is default to true.