Daniel.

I have seen this bug and have worked my way around it. Yes it's annoying but it's not too hard to work around, so I didn't kick up a fuss.

1) put each data rows unique ID in a cellTag
2) put a dictionary in your custom class

when the user selects a row, set dictionary.value(uniqueIndexValue) = true, and then set it to false when it id deselected.

In the listbox's sort event:

for n = 0 to me listcount-1
 if dictionary.haskey(me.celltag(n,0)) then
        me.selected(n) = dictionary.value(me.celltag(n,0))
 else
        me.selected(n) = false
 end
next


You could probably optimise this further, but I run with up to 5000 rows without much of a noticeable speed hit.

Cheers,
Tom



On 21/01/2007, at 10:10 PM, Daniel L. Taylor wrote:

If you select multiple rows in a ListBox, then sort, the selection will not be preserved properly.
http://www.realsoftware.com/feedback/viewreport.php?reportid=zgzqygiw

I bring this up on the list only because I consider it a dangerous bug. If you have data (RAM or DB driven) in a ListBox, and you allow a user to select and Delete said data, the user could inadvertently end up in a situation where they delete data they did not intend to delete.

This does not appear to affect ListBoxes set to single selection. If I recall correctly, ListBoxes bound to a database can't sort themselves, so those would be safe to. Ironically, I have and use a ListBox subclass which populates itself from a DB specifically so that it is not bound and can sort by header clicks, but I did that back in the 5.5 days so I don't know if that has changed in 200x.

I saw this tonight while testing an application and hit the ceiling. It has been around for a while, but I just never saw it or had a client complain. But it's one bug I do not like.

Daniel L. Taylor
Taylor Design
Computer Consulting & Software Development
[EMAIL PROTECTED]
www.taylor-design.com



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to