ComboBox ItemSource problem
Moderator: Rathinagiri
ComboBox ItemSource problem
I'm having trouble trying to show codes and their descriptions (two fields) in the drop-down of a ComboBox. The code is the one I want stored. For the record, I'm using 3.1.1 and XP SP3.
When I set up the definition as
ITEMSOURCE UCATHL->ATHLCD
everything compiles and runs perfectly, but (obviously) shows only the code.
When I change the definition to
ITEMSOURCE UCATHL->ATHLCD, UCATHL->ATHLNAME
it compiles, but then I get the following run-time error:
Program Error
Error BASE/1108 Argument error: AT
Called from AT(0)
Called from DEFINECOMBO(161)
Called from...
(Using "ITEMSOURCE UCATHL->ATHLNAME" on its own works fine, so it's a valid field.)
I've used the Combo.8 and Combo.9 samples, and they compile OK, but they don't show the codes (the first field listed) -- only the descriptions (the 2nd field listed), and no menu!, so I'm not sure what, if anything, that tells me!
Sample program is attached. It's very small -- just a few lines to open the table, index it, then load and activate the window, which has only the ComboBox in it -- but it gives me the same error; it just doesn't seem to like two fields in ItemSource!!
All thoughts and suggestions welcomed!
Tks.
CalScot
When I set up the definition as
ITEMSOURCE UCATHL->ATHLCD
everything compiles and runs perfectly, but (obviously) shows only the code.
When I change the definition to
ITEMSOURCE UCATHL->ATHLCD, UCATHL->ATHLNAME
it compiles, but then I get the following run-time error:
Program Error
Error BASE/1108 Argument error: AT
Called from AT(0)
Called from DEFINECOMBO(161)
Called from...
(Using "ITEMSOURCE UCATHL->ATHLNAME" on its own works fine, so it's a valid field.)
I've used the Combo.8 and Combo.9 samples, and they compile OK, but they don't show the codes (the first field listed) -- only the descriptions (the 2nd field listed), and no menu!, so I'm not sure what, if anything, that tells me!
Sample program is attached. It's very small -- just a few lines to open the table, index it, then load and activate the window, which has only the ComboBox in it -- but it gives me the same error; it just doesn't seem to like two fields in ItemSource!!
All thoughts and suggestions welcomed!
Tks.
CalScot
- Attachments
-
- UCATHL.ZIP
- (1.67 KiB) Downloaded 485 times
Re: ComboBox ItemSource problem
Hi!
What data do you want to present in ComboBox? first field, second field or both of them?
If both of them, you can join them:
UCATHL->AthlCd + UCATHL->AthlName
or
UCATHL->AthlCd - (" "+UCATHL->AthlName)
to move spaces to the end
What data do you want to present in ComboBox? first field, second field or both of them?
If both of them, you can join them:
UCATHL->AthlCd + UCATHL->AthlName
or
UCATHL->AthlCd - (" "+UCATHL->AthlName)
to move spaces to the end
Re: ComboBox ItemSource problem
Thanks, Marek.
I want only the code in the ComboBox itself, but both the code and its description to show in the dropdown. For example, the drop-down list may show:
ABC Description for code ABC
DEF Description for code DEF
GHI Description for code GHI
but I want only ABC or DEF or GHI (i.e., the 1st field, the "Code" field) to be "saved" in the box.
(I hope that's clear?)
Tks again.
CalScot
I want only the code in the ComboBox itself, but both the code and its description to show in the dropdown. For example, the drop-down list may show:
ABC Description for code ABC
DEF Description for code DEF
GHI Description for code GHI
but I want only ABC or DEF or GHI (i.e., the 1st field, the "Code" field) to be "saved" in the box.
(I hope that's clear?)
Tks again.
CalScot
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: ComboBox ItemSource problem
Hi Scotty
For multiple column / field GRID control may be more convenient.
Or as Marek noticed concatenate two fields into one string.
Happy HMG'ing
Since ComboBox is a single column control you can't assign more than one field to ItemSource property.CalScot wrote: ...
ITEMSOURCE UCATHL->ATHLCD, UCATHL->ATHLNAME
it compiles, but then I get the following run-time error:
...
For multiple column / field GRID control may be more convenient.
Or as Marek noticed concatenate two fields into one string.
Happy HMG'ing
Viva INTERNATIONAL HMG
Re: ComboBox ItemSource problem
Thanks, esgici.
You wrote:
and, from the Combo.8 sample:
Was it something that used to work but the feature has been taken away? Or is there some other thing that's causing it to not work? I don't know, so I'm still confused!
It certainly seems like the intention is (or was?) to have a dropdown box with 2 columns, such as a code and a full-text name for the code (with only the code being stored), as in the sample and in what I was trying to do. It would definitely be a useful thing to have and to get working!
Tks.
CalScot
PS: Also...
I think that the possibility of having the two fields in ITEMSOURCE is why the DROPDOWNWIDTH option exists: That width would need to be greater than the width of just the data in the box itself.
Sorry, but so many things point to saying that is -should- work, so I don't want to give up yet!
Tks again.
CalScot
You wrote:
but the documentation (HMG Reference) for ComboBox shows:Since ComboBox is a single column control you can't assign more than one field to ItemSource property.
Code: Select all
ITEMS <caItems>
ITEMSOURCE <ItemSourceField1> [ , <ItemSourceField2> ]
VALUE <nValue>
VALUESOURCE <ValueSourceField>
DISPLAYEDIT <lValue>
Code: Select all
DEFINE COMBOBOX Combo_2
ROW 10
COL 250
ITEMSOURCE CIDADES->CODIGO , CIDADES->DESCRICAO
VALUE 2
WIDTH 200
HEIGHT 100
IMAGE aImages
DROPPEDWIDTH 350
ONDROPDOWN PlayBeep()
ONCLOSEUP PlayAsterisk()
END COMBOBOX
It certainly seems like the intention is (or was?) to have a dropdown box with 2 columns, such as a code and a full-text name for the code (with only the code being stored), as in the sample and in what I was trying to do. It would definitely be a useful thing to have and to get working!
Tks.
CalScot
PS: Also...
I think that the possibility of having the two fields in ITEMSOURCE is why the DROPDOWNWIDTH option exists: That width would need to be greater than the width of just the data in the box itself.
Sorry, but so many things point to saying that is -should- work, so I don't want to give up yet!
Tks again.
CalScot
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: ComboBox ItemSource problem
Hi Scotty
But as notified a little down of this doc page, at "Image Support" section, this two field notation is for Image support; not for automatically concatenate two fields nor for make a two column combobox.
In fact, with this way its possible build a two column ComboBox; but first column is for images.
Happy HMG'ing
You are write, by a quick read HMG Doc and and COMBO.8 sample, its seem that its possible to define two field as ITEMSOURCE....
Was it something that used to work but the feature has been taken away? Or is there some other thing that's causing it to not work? I don't know, so I'm still confused!
But as notified a little down of this doc page, at "Image Support" section, this two field notation is for Image support; not for automatically concatenate two fields nor for make a two column combobox.
In fact, with this way its possible build a two column ComboBox; but first column is for images.
Sorry, but IMHO no relation exist between this issue and dropdown.It certainly seems like the intention is (or was?) to have a dropdown box with 2 columns, such as a code and a full-text name for the code (with only the code being stored), as in the sample and in what I was trying to do. It would definitely be a useful thing to have and to get working!
Happy HMG'ing
Viva INTERNATIONAL HMG
Re: ComboBox ItemSource problem
Thanks to the replies by Marek & esgici, I have a solution. (Updated sample attached.)
The dropdown list shows the concatenated code and description fields, but only the code field shows in the box. When the data is saved, the field it is saved to is the same length as the code, so the data gets truncated, only the code is saved, and the description data is discarded.
It does mean using a different, fixed-width font, but it works. ( I wish that there was a fixed-width version of Arial !! )
Thanks again.
CalScot
The dropdown list shows the concatenated code and description fields, but only the code field shows in the box. When the data is saved, the field it is saved to is the same length as the code, so the data gets truncated, only the code is saved, and the description data is discarded.
It does mean using a different, fixed-width font, but it works. ( I wish that there was a fixed-width version of Arial !! )
Thanks again.
CalScot
- Attachments
-
- UCATHL.ZIP
- (2 KiB) Downloaded 521 times
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: ComboBox ItemSource problem
Hi Scotty
Nonetheless GRID will be may convenient to your need, I think.
Regards
Good implementation, thanks to shareCalScot wrote:...I have a solution. (Updated sample attached.)...
Nonetheless GRID will be may convenient to your need, I think.
Regards
Viva INTERNATIONAL HMG
-
- Posts: 388
- Joined: Wed Nov 21, 2012 7:14 pm
- Location: México
Re: ComboBox ItemSource problem
Bonita implementación CalScot...
Gracias por compartir...
Saludos
Polo
*----------------------------------------------------------------------------------------------------------------------------
Nice implementation CalScot ...
Thanks for sharing ...
regards
Polo
Gracias por compartir...
Saludos
Polo
*----------------------------------------------------------------------------------------------------------------------------
Nice implementation CalScot ...
Thanks for sharing ...
regards
Polo