how to set ListCtrl item after sort by some column

Hi, I have problem to modify a listctrl item.

The ListCtrl is instanced with wx.ListCtrl and wx.lib.mixins.listctrl.ColumnSorterMixin
(just follows the demo), in report view, and multicolumns.

I have made such event binding that after double click on a row of item,
a dialog appears and is filled with text of that row item, so that I can
modify the text. the dialog is not modal, so at that time, I can still
click the column header to sort the list and focused on another row.

after the modify complete, the text should be set to orginal row item,
but I don't know how to find the index now. the index from evt.GetData() isn't
correct after sorting.

so how can I update the row item?

Zhang

Create a hidden column, give each row a unique value for that column,
keep that information in your dialog, and when updating, scan all rows
for that unique value.

Alternatively, use the wx.lib.mixins.listctrl.TextEditMixin . Maybe you
won't need your dialog anymore.

- Josiah

···

zyf_sz <zyf_sz@tom.com> wrote:

Hi, I have problem to modify a listctrl item.

The ListCtrl is instanced with wx.ListCtrl and wx.lib.mixins.listctrl.ColumnSorterMixin
(just follows the demo), in report view, and multicolumns.

I have made such event binding that after double click on a row of item,
a dialog appears and is filled with text of that row item, so that I can
modify the text. the dialog is not modal, so at that time, I can still
click the column header to sort the list and focused on another row.

after the modify complete, the text should be set to orginal row item,
but I don't know how to find the index now. the index from evt.GetData() isn't
correct after sorting.

so how can I update the row item?

zyf_sz wrote:

Hi, I have problem to modify a listctrl item.

The ListCtrl is instanced with wx.ListCtrl and wx.lib.mixins.listctrl.ColumnSorterMixin
(just follows the demo), in report view, and multicolumns.

I have made such event binding that after double click on a row of item,
a dialog appears and is filled with text of that row item, so that I can
modify the text. the dialog is not modal, so at that time, I can still
click the column header to sort the list and focused on another row.

after the modify complete, the text should be set to orginal row item,
but I don't know how to find the index now. the index from evt.GetData() isn't
correct after sorting.

Since you are using ColumnSorterMixin then you have unique values in each item's data value. So you can remember that value for the item you are editing, and then look it up later by its data value using FindItemData.

···

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

Thanks, Robin

FindItemData works well.

Zhang