Sorting and wxListCtrl

Many thanks!

Just one follow up please ...

The wxWindows documentation indicates that in
self.list.SetItemData(0, i)
the second arg is the value you mentioned, but
what is the first arg? Does an item correspond
to a cell or a row?

The reason I ask is that in the listctrl demo
program, the call made is
self.list.SetItemData(x, key)
where x ranges from 0 to the number of items in a
hash storing the data, and key = x + 1.
But doing this in my example doesn't work.

Again, thank you for your help!!!
Dave

ยทยทยท

djneu@att.net wrote:
> Hi-
>
> I'm using wxPython 2.4.0.1 on Windows 2000.
> I've included a small example which includes
> a wxListCtrl, and shows how to control
> the sorting of columns.
>
> To get it to work I had to make the following
> call:
> self.list.SetItemData(0, i)
>
> My questions are:
>
> a) Why is this call necessary?

The values passed to the compare function are not row indexes but are
the data values associated with the item, so if the items have no data
value you have no way to get to the column values to be sorted.

> b) What exactly does it do?

Associates a data value with the list item. Even if the item changes
position in the control the data value associated with it will stay the
same.

> c) Is this the "correct" way to handle sorting?
>

Yes. Another way is to use the wxLC_VIRTUAL style and instead of
preloading values into the control it will ask you for them when it
needs to display them. Then sorting becomes just a matter of sorting
your data and then refreshing the control.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org