New topic: 

Working with Multiple Selections in a ListBox

<http://forums.realsoftware.com/viewtopic.php?t=46426>

         Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic          Author  
Message        RonBower          Post subject: Working with Multiple Selections 
in a ListBoxPosted: Thu Jan 03, 2013 12:14 pm                         
Joined: Wed Feb 01, 2012 3:06 pm
Posts: 43                I have a ListBox in my application that has been in 
use pretty much since day 1. The list box has multiple columns and also has a 
Context Sensitive menu that brings up a menu on right click that allows the 
user to select to either Edit or Delete the item on the row that was clicked.

Recently, some users have asked to be able to select multiple rows and then 
right click to edit or delete all the selected rows. I've set the SelectionType 
to SelectionMultiple and the user can now select (highlight) several rows 
either in groups or individually. However, when the user right clicks anywhere 
in the ListBox to bring up the Context Sensitive menu, all selected rows are 
deselected and ONLY the row that received the right click is selected.

How can I have the multiple selected rows preserved for the context sensitive 
menu to "see" ?

Ron Bower
Ellicott City, MD   
                             Top                charonn0          Post subject: 
Re: Working with Multiple Selections in a ListBoxPosted: Thu Jan 03, 2013 12:35 
pm                                 
Joined: Mon Apr 02, 2007 2:08 am
Posts: 1058
Location: San Francisco, CA, USA                Try returning true from the 
MouseDown event if IsContextualClick is true.      
_________________
Boredom Software  
                             Top                RonBower          Post subject: 
Re: Working with Multiple Selections in a ListBoxPosted: Thu Jan 03, 2013 2:33 
pm                         
Joined: Wed Feb 01, 2012 3:06 pm
Posts: 43                Wow !  That seems to work great - I would have NEVER 
come up with that on my own.

Here's another challenge I'm struggling with. When a user clicks (normal left 
click) on a row, the row is selected and highlighted. Sometimes the click was 
an error. It would be nice to have the selection status toggle on/off with each 
click.

I tried coding a toggle routine within the ListBox "CellClick" event - 
something like:

If ( Me.Selected( row ) ) Then
 Me.Selected( row ) = FALSE
Else
  Me.Selected( row ) = TRUE
EndIf

But that doesn't seem to do anything - UNLESS I set SelectionType to 
SelectionSingle.

Any suggestions for how to toggle the selected status on/off with each left 
click - ASSUME that no other rows are selected.

Ron Bower
Ellicott City, MD   
                             Top                timhare          Post subject: 
Re: Working with Multiple Selections in a ListBoxPosted: Thu Jan 03, 2013 6:13 
pm                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11944
Location: Portland, OR  USA                Make sure you return True from 
CellClick after you toggle the selection.  Otherwise, the system will process 
the click and select the row.   
                             Top                RonBower          Post subject: 
Re: Working with Multiple Selections in a ListBoxPosted: Fri Jan 04, 2013 9:38 
am                         
Joined: Wed Feb 01, 2012 3:06 pm
Posts: 43                Thanks for the hint - I will try that when I can get 
back at the code.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to