On Oct 30, 2004, at 11:09 AM, CV wrote:
Hi; I'm hoping someone can provide some insight on either of these
two questions:
(1) Is there a way to add items programmatically to a multiple
selection in a ListBox?
Do you mean that a block of rows are selected and you wish to add a
new row to the end of the group? If so, you would use ListIndex,
Selected, and SelCount to locate the LastRow in the selected group,
then use
ListBox1.InsertRow LastRow + 1, strItem to add the items.
No, sorry -- I meant add to the selection, not add to the list.
I've tried doing this with myListBox.Selected(RowNum) = True and it
clears the previous selection. myListBox.ListIndex = RowNum doesn't
work either, but I didn't think it would.
Now I think I see what you're after. :) You want to highlight some
additional existing rows beyond a block of currently selected rows? In
this case, the current ListIndex holds the row number of the first of
the currently selected rows. So you would do something like:
dim i as integer
dim NumNewSelections as integer // the number of additional rows to
highlight
dim LastRowToSelect as integer
NumNewSelections = 3 //for example, to highlight 3 rows beyond
existing selections
LastRowToSelect = ListBox1.ListIndex + ListBox1.SelCount +
NumNewSelections - 1
For i = ListBox1.ListIndex to LastRowToSelect
ListBox1.Selected(i) = true
Next
HTH,
Jack
Thank you, Jack. But as I mentioned I have been trying to use the
Selected(i) = True approach and it keeps clearing the previous
selection, e.g. using your example it doesn't "grow" the selection, it
just keeps moving down the list and selecting a single row. I'm
starting to think that I'm doing something in code that is
inadvertently clearing the previous selection each time.
David
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|