Hi all,
I¹ve got a window with two listboxes, each with just a single column. When
the user double-clicks an item in one of the lists, it moves the item to the
other list and removes it from the source list.
This is the code in the DoubleClick event of the source listbox:
ListBoxTarget.AddRow ListBoxSource.Cell(ListBoxSource.ListIndex,0)
ListBoxSource.RemoveRow(ListBoxSource.ListIndex)
This is the problem I¹m seeing: If the user double-clicks a row, then
immediately double-clicks the next row, as it moves up to take the position
vacated by the first row that just moved to the other listbox, I get an
Out-Of-Bounds exception on ListBoxSource. The debugger reveals that at that
point, ListBoxSource.ListIndex = -1.
It seems as if the
I¹ve come up with a workaround, by enclosing the above code in an If
statement like this:
if ListBoxSource.ListIndex >= 0 then
ListBoxTarget.AddRow ListBoxSource.Cell(ListBoxSource.ListIndex,0)
ListBoxSource.RemoveRow(ListBoxSource.ListIndex)
end if
But this also has the effect of making the listbox stop responding to
double-clicks at all if they¹re made too quickly.
Has anyone else seen anything like this, or perhaps have a better way of
handling this particular situation? Also, is this potentially a bug in the
listbox control? The entries have already refreshed themselves visually when
the error shows up, it just seems that the ListIndex is not yet updated by
the time a DoubleClick event is permitted to fire on the listbox again.
Thanks in advance!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>