Real Software Forums
http://forums.realsoftware.com/

Multicolumn combobox
http://forums.realsoftware.com/viewtopic.php?f=5&t=45889
Page 1 of 1

Author:  FCampos [ Tue Nov 13, 2012 12:39 pm ]
Post subject:  Multicolumn combobox

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.

Author:  markwalsh [ Tue Nov 13, 2012 1:40 pm ]
Post subject:  Re: Multicolumn combobox

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.

Author:  FCampos [ Sun Nov 25, 2012 6:33 am ]
Post subject:  Re: Multicolumn combobox

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.

Author:  Bimal [ Mon Nov 26, 2012 12:28 am ]
Post subject:  Re: Multicolumn combobox

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.

Author:  FCampos [ Mon Dec 10, 2012 5:00 am ]
Post subject:  Re: Multicolumn combobox

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.

Author:  timhare [ Mon Dec 10, 2012 5:38 pm ]
Post subject:  Re: Multicolumn combobox

I would highly recommend not using a datacontrol. A little bit more code gives you the same functionality and much greater freedom of control.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/