Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Selecting multiple rows in a listbox (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: One more question about FolderItems
Next thread: Re: Quick question about GetFolderItem.Child() method


Strange problem with legacy Sybase database memo fields   -   kev actis.com
  Selecting multiple rows in a listbox   -   Tobias Eichner
   Re: Selecting multiple rows in a listbox   -   Light Blue Software
    Re: Selecting multiple rows in a listbox   -   Tobias Eichner

Selecting multiple rows in a listbox
Date: 03.08.12 13:17 (Fri, 3 Aug 2012 13:17:31 +0100 (BST))
From: Tobias Eichner
Hello,

I'm trying to programmatically select multiple items in a listbox (data origins from a regular expression search); for example:

    While RegExMatch <> Nil

      For x As Integer = 0 To Window.ListBox.ListCount-1
        If Window.ListBox.List(x) = RegExMatch.SubExpressionString(1) Then
          Window.ListBox.ListIndex = x 'Just highlights ONE item, even there are MULTIPLE.
        End If
      Next x
      RegExMatch = RegEx.Search()
    Wend

(Method is part of a module.)

You see the problem: If there are multiple items to be selected, ListBox.ListIndex only marks one of them. I haven't found a way to manage multiple items this way. I guess the solution is quite simple, but I don't see it.

Thanks for your help.

Bye,
Tobias.

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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Selecting multiple rows in a listbox
Date: 03.08.12 13:40 (Fri, 3 Aug 2012 13:40:32 +0100)
From: Light Blue Software
I don't think you can do what you're after with ListIndex. The LR says:
"If the ListBox is in multiple-row selection mode, then the number of the lowest selected row is returned"

You could use Selected instead, something like

Window.ListBox..Selected(ListIndex) = True

Have a look at listbox.selected in the language reference - should give you a pointer.

Hamish


On 3 Aug 2012, at 1:17pm, Tobias Eichner <<email address removed>> wrote:

> Hello,
>
> I'm trying to programmatically select multiple items in a listbox (data origins from a regular expression search); for example:
>
> While RegExMatch <> Nil
>
> For x As Integer = 0 To Window.ListBox.ListCount-1
> If Window.ListBox.List(x) = RegExMatch.SubExpressionString(1) Then
> Window.ListBox.ListIndex = x 'Just highlights ONE item, even there are MULTIPLE.
> End If
> Next x
> RegExMatch = RegEx.Search()
> Wend
>
> (Method is part of a module.)
>
> You see the problem: If there are multiple items to be selected, ListBox.ListIndex only marks one of them. I haven't found a way to manage multiple items this way. I guess the solution is quite simple, but I don't see it.
>
> Thanks for your help.
>
> Bye,
> Tobias.

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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Selecting multiple rows in a listbox
Date: 03.08.12 13:46 (Fri, 3 Aug 2012 13:46:40 +0100 (BST))
From: Tobias Eichner
Hello Hamish,

yes, now I found it, too. Works well... not sure why I have overseen .selected during my own search. Thank you.

Bye,
Tobias.

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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>