Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Dec 14, 2017 5:57 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Working with Multiple Selections in a ListBox
PostPosted: Thu Jan 03, 2013 12:14 pm 
Offline
User avatar

Joined: Wed Feb 01, 2012 3:06 pm
Posts: 68
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

_________________
Ron Bower
Ellicott City, MD


Top
 Profile  
Reply with quote  
 Post subject: Re: Working with Multiple Selections in a ListBox
PostPosted: Thu Jan 03, 2013 12:35 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Try returning true from the MouseDown event if IsContextualClick is true.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Working with Multiple Selections in a ListBox
PostPosted: Thu Jan 03, 2013 2:33 pm 
Offline
User avatar

Joined: Wed Feb 01, 2012 3:06 pm
Posts: 68
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

_________________
Ron Bower
Ellicott City, MD


Top
 Profile  
Reply with quote  
 Post subject: Re: Working with Multiple Selections in a ListBox
PostPosted: Thu Jan 03, 2013 6:13 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
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
 Profile  
Reply with quote  
 Post subject: Re: Working with Multiple Selections in a ListBox
PostPosted: Fri Jan 04, 2013 9:38 am 
Offline
User avatar

Joined: Wed Feb 01, 2012 3:06 pm
Posts: 68
Thanks for the hint - I will try that when I can get back at the code.

_________________
Ron Bower
Ellicott City, MD


Top
 Profile  
Reply with quote  
 Post subject: Re: Working with Multiple Selections in a ListBox
PostPosted: Thu Feb 14, 2013 12:03 pm 
Offline

Joined: Mon Dec 07, 2009 7:30 pm
Posts: 121
Location: Europe/Italy
I want user to be able to select maximum 2 rows and then compare the values in lets say column 2 of those selected rows.

Question: In properties 'Selection Type' I have multiple, but how do I prevent more than 2 simultaneous row selections?


Top
 Profile  
Reply with quote  
 Post subject: Re: Working with Multiple Selections in a ListBox
PostPosted: Thu Feb 14, 2013 12:37 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
go through the box and count the selections... once you reach the maximum you allow.... programmtically deselect any remaining rows

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Working with Multiple Selections in a ListBox
PostPosted: Thu Feb 14, 2013 1:10 pm 
Offline

Joined: Mon Dec 07, 2009 7:30 pm
Posts: 121
Location: Europe/Italy
Thanks.. Gave me an idea. How about this in the CellClick event:

if Keyboard.AsyncShiftKey then
Return true
else
If keyboard.AsyncControlKey then

if firstselection = false then
return true
elseif firstselection = true and secondselection = true then
return true
else
secondselection = true
end if
else
firstselection = true
secondselection = false
End If
end if


And do whatever from retrieved cells.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group