Hi all,
In a window that uses a wxListCtrl with a wxColumnSorterMixin, I needed to dynamically hide and show a certain number of columns (the last columns of a set).
My code was doing a list.ClearAll() then rebuild and populate all columns. It worked but the sorting was not working after changing the column shown.
So I called wxColumnSorterMinin.__init__ again (after the column number change) to solve the problem, but that did not help either.
wxColumnSorterMinin.__init__ is:
def __init__(self, numColumns):
self._colSortFlag = [0] * numColumns
self._col = -1
list = self.GetListCtrl()
if not list:
raise ValueError, "No wxListCtrl available"
EVT_LIST_COL_CLICK(list, list.GetId(), self.__OnColClick)
So I added a new wxColumnSorterMinin method:
def SetColumnCount(self, newNumColumns):
self._colSortFlag = [0] * newNumColumns
self._col = -1
Now, i call wxColumnSorterMinin.__init__() once and when I change the columns that are shown I only call xColumnSorterMinin.SetColumnCount()
This works. The columns retain their ability to sort.
Is there a better way?
Thanks
Pierre