Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Nov 18, 2017 8:59 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Multicolumn combobox
PostPosted: Tue Nov 13, 2012 12:39 pm 
Offline

Joined: Tue Nov 13, 2012 11:19 am
Posts: 7
Hi to everybody.

I'm not sure if this is the right place to explain what I want.

All my tables in my BD have an integer primary key and on other tables the related field to that PK, like this:
Table: Colours
Fields: IDColour; Colour
Values: 1; Black
2; Red
3; Blue
4; White
... and so on

Table: Person
Fields: IDPerson; Name; FavColour
Values: 1; Susan; 2
2; Peter; 3
3; John; 2
... and so on

If I make a form of table 'Persons' and want to put a combo to insert the colour in field 'FavColour'
Is there a combobox that has two columns (IDColour, Colour) and shows only the column colour, but what I'm saving in my field is the first column?
If this combo would have the these properties:
DataSource: SELECT IDColour, Colour FROM Colours;
DataField: FavColour 'The field of the table 'Persons'
NumberOfColumns: 2
PrincipalColumn: 1 'The column that I want to save the value
ColumnsWidth: 0px;60px '0 px IDColour, 60 px Colour. So only shows the second column

I 'm new on RealBasic, so I don't know if there is a custom combobox like this, or close to it.
Is there something like this? And will it work on Mac?

Thank you.


Top
 Profile  
Reply with quote  
 Post subject: Re: Multicolumn combobox
PostPosted: Tue Nov 13, 2012 1:40 pm 
Offline

Joined: Wed May 20, 2009 4:43 pm
Posts: 958
Combobox items have a 'RowTag' property - you can store the ID in the RowTag and display the color in the combobox row. When an item is selected, get the RowTag for that row and store that in the DB.

Note that if you are using a combobox, and the user enters text which isn't in the list, it will not have a rowtag. Use a PopupMenu if you don't want to allow the user to enter a value which isn't in the list.

_________________
RB 2009r4 Windows XP


Top
 Profile  
Reply with quote  
 Post subject: Re: Multicolumn combobox
PostPosted: Sun Nov 25, 2012 6:33 am 
Offline

Joined: Tue Nov 13, 2012 11:19 am
Posts: 7
markwalsh wrote:
Combobox items have a 'RowTag' property - you can store the ID in the RowTag and display the color in the combobox row. When an item is selected, get the RowTag for that row and store that in the DB.

Note that if you are using a combobox, and the user enters text which isn't in the list, it will not have a rowtag. Use a PopupMenu if you don't want to allow the user to enter a value which isn't in the list.


Thank you.
It's not perfect, but I'll try it.


Top
 Profile  
Reply with quote  
 Post subject: Re: Multicolumn combobox
PostPosted: Mon Nov 26, 2012 12:28 am 
Offline

Joined: Mon Jan 16, 2012 8:08 am
Posts: 161
Location: India
FCampos wrote:
Thank you.
It's not perfect, but I'll try it.



Then exactly want u want FCampos :( . U can populate the color value in the combobox and u can set the "id" (not visible to user) of the color in the rowtag Property of the combobox. Further if u have any problem let me know.

Thanks
Bimal.


Top
 Profile  
Reply with quote  
 Post subject: Re: Multicolumn combobox
PostPosted: Mon Dec 10, 2012 5:00 am 
Offline

Joined: Tue Nov 13, 2012 11:19 am
Posts: 7
Bimal wrote:
FCampos wrote:
Thank you.
It's not perfect, but I'll try it.



Then exactly want u want FCampos :( . U can populate the color value in the combobox and u can set the "id" (not visible to user) of the color in the rowtag Property of the combobox. Further if u have any problem let me know.

Thanks
Bimal.



Thank you very much for your answers and support. And sorry for answering so late.

I'll try to explain what I see using this control (combobox, popup menu, ...)

If I use a comboxbox with datacontrol binding the combobox to a data field, what it's stored in my field is what I'm seeing in my combobox, not with the rowtag value. I have to bind another control (hidden) to my datafield and update that control with my combobox rowtag when I update the combobox. Analogously, if I move to a record, I have to update the value of my combobox via code because the values of the combobox are not the ID's of the table that is based my combobox values.

Please, if I'm wrong or there is another way to do it, an easier way, let me know.
An example would be appreciated.

Thanks.
Fernando.


Top
 Profile  
Reply with quote  
 Post subject: Re: Multicolumn combobox
PostPosted: Mon Dec 10, 2012 5:38 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
I would highly recommend not using a datacontrol. A little bit more code gives you the same functionality and much greater freedom of control.


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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group