Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Jan 20, 2018 5:29 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Popup Menu management
PostPosted: Sat Dec 01, 2012 8:45 pm 
Offline
User avatar

Joined: Sun Feb 20, 2011 1:05 pm
Posts: 6
Location: Boston, MA
Playing around with various ways to manage a popup menu and it's contents and changes I thought I'd post something to the group for comment.

I got a database application with a popup menu to choose one of the fields, the items in the popup are derived from another table in the database. The particular choice for a record is stored in the table for that record. As it is now when I load that record I only set the popup menu text to just the one item. Then if the user edit/changes the popup I have to go and load all the choices. That's kind of awkward as right now I'm using the mousedown event to trigger that and the user has to click twice.

What I think I'd really like to do is load all the popup choices when the record loads and then set the popup to the correct item based on the current value in the database. Then I might use something like the change event to manage any changes. Am I heading in the right direction and can someone point me toward some sample code. I didn't see anything in the example projects.

Thank you.

Duane Mitchell

_________________
Next Generation Solutions | http://www.nxgnsol.com | 617-539-6050


Top
 Profile  
Reply with quote  
 Post subject: Re: Popup Menu management
PostPosted: Mon Dec 03, 2012 7:57 am 
Offline
User avatar

Joined: Sun Feb 20, 2011 1:05 pm
Posts: 6
Location: Boston, MA
OK, so I have been thinking about this and had this thought. First, when the window is opened the popup menu will load the data from the database table. Then when the user data is loaded the popup will be set to whatever it should be for that user. Being new to this the way I would do this is to create an array containing the popup options and then cycle through them until I got a match. Then use either the cycle count as some sort of index or could I use a textual match of somekind? Suggestions?

_________________
Next Generation Solutions | http://www.nxgnsol.com | 617-539-6050


Top
 Profile  
Reply with quote  
 Post subject: Re: Popup Menu management
PostPosted: Mon Dec 03, 2012 8:39 am 
Offline

Joined: Fri Jan 23, 2009 9:18 am
Posts: 104
Location: Summerfield, Florida
No need for an additional array.
Just loop through the popup menu and set the listindex on a match.

Subclass the popup menu and add a method

Sub SetMenuItem(searchItem as String)
// Search for a match
For i as Integer = 0 to me.ListCount - 1
me.ListIndex = i
if me.text = searchItem then Return
Next

// No match found
me.ListIndex = -1
End Sub


Then call it with the search item
popupmenu1.SetMenuItem (searchText)


Jim


Top
 Profile  
Reply with quote  
 Post subject: Re: Popup Menu management
PostPosted: Wed Dec 05, 2012 9:09 am 
Offline
User avatar

Joined: Sun Feb 20, 2011 1:05 pm
Posts: 6
Location: Boston, MA
Cool! Thank you!

_________________
Next Generation Solutions | http://www.nxgnsol.com | 617-539-6050


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group