Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Nov 19, 2017 2:37 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: multiple row tags in listbox
PostPosted: Thu May 23, 2013 10:34 pm 
Offline

Joined: Sat Jun 23, 2007 12:44 pm
Posts: 45
I was wondering if anyone has implemented a listbox with multiple rowtags for a single row? Any ideas on how to implement it?

ie:
mylistbox1.rowtag(row as integer) as variant//built in rowtag method
mylistbox1.rowtag1(row as integer) as variant//extended method?
mylistbox1.rowtag2(row as integer) as variant// etc...
mylistbox1.rowtag3(row as integer) as variant// etc...

perhaps using a listbox subclass with a dictionary and get and set methods?


Top
 Profile  
Reply with quote  
 Post subject: Re: multiple row tags in listbox
PostPosted: Thu May 23, 2013 10:38 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Since rowtag is a variant... you can assign a collection or dictionary, or custom class for that matter

_________________
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: multiple row tags in listbox
PostPosted: Fri May 24, 2013 1:07 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
You can also use CellTag to attach a variant to each column of the row, if that's what you're after.


Top
 Profile  
Reply with quote  
 Post subject: Re: multiple row tags in listbox
PostPosted: Sun May 26, 2013 8:49 am 
Offline

Joined: Sat Jun 23, 2007 12:44 pm
Posts: 45
thanks for responding,

I decided to go with a dictionary or custom class but is there any way for the listbox to always "know" that the row tag is my dictionary or custom class? If there is not a way, I have used isA to "cast" it but I'd rather not have to rely on this method (Also hoping the word "cast" is being used correctly here if not, please correct me).


Function convertDictionaryFromRowTag(myRowTag as Variant) As myListboxDictionary
dim dict as new myListboxDictionary

if myRowTag isa myListboxDictionary then
dict = myListboxDictionary(myRowTag)
end if

Return dict
End Function


Top
 Profile  
Reply with quote  
 Post subject: Re: multiple row tags in listbox
PostPosted: Sun May 26, 2013 9:55 am 
Offline

Joined: Wed May 20, 2009 4:43 pm
Posts: 958
jojoSATX wrote:
Function convertDictionaryFromRowTag(myRowTag as Variant) As myListboxDictionary
dim dict as new myListboxDictionary

if myRowTag isa myListboxDictionary then
dict = myListboxDictionary(myRowTag)
end if

Return dict
End Function

I would recommend not creating a new dictionary/class instance in this method. If the rowtag is not of the expected type, you are creating a new instance and your calling method will not know that the returned value is not the actual rowtag for the row. You shouldn't have any problems if you are only reading the values, but if your calling method alters the contents (or the code is changed at a later date to alter the contents) any changes will not be updated in the actual rowTag. And that could be hard to locate the cause by that time.

IMHO, it's best to return null so that the calling method will know that the rowtag is not the expected type, and handle the situation properly.


I personally prefer Tim's suggestion to use CellTags. You can access the celltag of a cell that is not displayed (if your listbox has 5 columns, you can still access celltags from 6 to the maximum), giving you a large number of available cells to store data.

_________________
RB 2009r4 Windows XP


Top
 Profile  
Reply with quote  
 Post subject: Re: multiple row tags in listbox
PostPosted: Mon May 27, 2013 6:24 pm 
Offline

Joined: Sat Oct 01, 2005 5:19 pm
Posts: 3216
Personally I always use a class & Rowtag, and save the celltags for the cells i.e. text colour, font, drawing the text ...

Dim myClass As New Class1
listbox1.AddRow"Hello"
listbox1.RowTag(listbox1.LastIndex) = myClass


In the Change Event (or anywhere I want to see what's in the Class)

If Listbox1.ListIndex <> - 1 then
Dim myClass As Class1 = listbox1.RowTag(listbox1.listIndex) //or the appropriate number


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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