Hans L


I read everywhere about the so called "dropdown list box", but, while I have searched long and hard, I cannot find any description of how to create such a beast. Kind of embarrasing, but ...

Also, as a stopgap, I use a combo box to select indexes to list various sets of data in a grid, and I do not have anything in the ControlSource. I have 1 C Value in RowSourceType and then six list items in RowSource. While any of these items I click on shows up in the text area of the combobox, I have not been able to figure out how to make one of them show up in the text area when the combobox is created. Where do I put the code

Let me be specific:

Let' say that the RowSource have "Alpha,Bravo,Charlie,Delta,Echo,Foxtrot" in it.

When the combobox is created, let's say that index TAG "Bravo" is in effect. So, I have the following code in the combobox Init method:

DO CASE
CASE TAG() = 'Alpha'
THIS.Value = 'Alpha'
CASE TAG() = 'Bravo'
THIS.Value = 'Bravo'
CASE TAG() = 'Charlie'
THIS.Value = 'Charlie'
CASE TAG() = 'Delta'
THIS.Value = 'Delta'
CASE TAG() = 'Echo'
THIS.Value = 'Echo'
CASE TAG() = 'Foxtrot'
THIS.Value = "Foxtrot"
ENDCASE

In other words, I was hoping that by setting "Value" to "Bravo" in this case would put "Bravo" in the combobox text area when the box was created. Not so. So, the question is, should I replace "Value" with something else (what ) and where should I place the code if not in Init method

I assume the answers would be the same if I ever understood how to create a Dropdown List Box :-)

Thanks for your kind help.

Regards,

Hans L








Re: dropdown list box

dni


It should work.You may try to put code in load method. If you need only for display purpose you may use property DisplayValue.







Re: dropdown list box

Hans L

I will try

Load C Value

Load C Display value


Would you by any chance know how to create that elusive DropDown List Box

Hans L





Re: dropdown list box

Vladimir Zografski

Hi Hans TAG() return in UPPER
Try This

Code Block

PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
**************************************************
*-- Form: form1

DEFINE CLASS form1 AS form


DoCreate = .T.
Caption = "Form1"
Name = "Form1"

ADD OBJECT combo1 AS combobox WITH ;
Height = 31, ;
Left = 65, ;
Style = 2, ;
Top = 58, ;
Width = 225, ;
Name = "Combo1"

PROCEDURE Load
CREATE CURSOR Temp (FldInt I,FldChr C(20), Fld3 C(20))
INSERT INTO Temp VALUES(1, [dsgf],[fjg])
INSERT INTO Temp VALUES(3, [sdfd],[xcb])
INSERT INTO Temp VALUES(2, [xcvx],[cvb])
INDEX ON FldInt TAG Alpha
INDEX ON FldChr TAG Bravo
INDEX ON Fld3 TAG Charlie

SET ORDER TO Bravo
ENDPROC


PROCEDURE combo1.Init
This.AddItem('Alpha')
This.AddItem('Bravo')
This.AddItem('Charlie')
This.AddItem('Delta')
This.AddItem('Echo')
This.AddItem('Foxtrot')

DO CASE
CASE UPPER(TAG()) = UPPER('Alpha')
THIS.Value = 'Alpha'
CASE UPPER(TAG()) = UPPER('Bravo')
THIS.Value = 'Bravo'
CASE UPPER(TAG()) = UPPER('Charlie')
THIS.Value = 'Charlie'
CASE UPPER(TAG()) = UPPER('Delta')
THIS.Value = 'Delta'
CASE UPPER(TAG()) = UPPER('Echo')
THIS.Value = 'Echo'
CASE UPPER(TAG()) = UPPER('Foxtrot')
THIS.Value = "Foxtrot"
ENDCASE
ENDPROC
ENDDEFINE







Re: dropdown list box

Hans L

I certainly will.

Thanks, Vladimir!!!

Hans L




Re: dropdown list box

Hans L

Vladimir, if I had only read your first line ...

"TAG() return in UPPER"

... carefully! That was the problem. It now works like a charm.

Thank you,

Hans L




Re: dropdown list box

dni

Good point ! I did not know TAG() returns a uppercase character string.






Re: dropdown list box

Hans L

dni wrote:

Good point ! I did not know TAG() returns a uppercase character string.



You can see it in that when you add the tag name in project.table, if you add lower case, it sooner or later changes to upper case. But it did not tip me off either.

Hans L




Re: dropdown list box

Vladimir Zografski

Hi Hans,
Glad to be of help.

I'm sorry for my bad english.





Re: dropdown list box

Hans L

You should hear my Slavic!

Hans L




Re: dropdown list box

Tamar E. Granor

A dropdown list box is just a combo with Style set to 2.

Tamar




Re: dropdown list box

Hans L

Thank you,Tamar!!!

Hans L