Search code examples
c#objectlistview

Detect Column Hidden or Shown


I'm using the ObjectListView control from here.

I'd like to detect when a user right clicks the headers and hides or shows a column. Basically a ColumnVisibilityChanged event. The reason I want to detect this is to save the visible columns between sessions.

The ColumnWidthChanged event fires when this occurs (not on the column that has been removed), so I could iterate through AllColumns and check the value of IsVisible. However, that seems hacky and I'd like to avoid it. Also, that would get run several times when it didn't need to.

Anyone know of a better way of detecting a column being hidden or shown?


Solution

  • Well I found a solution that wasn't quite what I was looking for, but possibly better.

    ObjectListView has SaveState() and RestoreState() methods as described here.