realbasic-nug
[Top] [All Lists]

Re: Multiple Selections in ListBoxes and Dialogs

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Multiple Selections in ListBoxes and Dialogs
From: David Harris <dharris at davosystems dot com>
Date: Sat, 30 Oct 2004 14:41:08 -0400
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <5B5BA34E-29CC-11D9-91C6-0003930333B8 at davosystems dot com> <AFF2FB94-2A85-11D9-B2D4-000393C6C4C4 at hit dot net>
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>

<Prev in Thread] Current Thread [Next in Thread>