Combo box, (style = CsDropdownlist) show default value

Hi,

I am using delphi 3.02

I have a combo box with a fixed known number of values (these are the ONLY valid values, so I have made the type CsDropDownList).

When I display the combo box I want a defuault value already shown, but currently it just shows blank until you select a value. I have tried code like combobox1.text := 'Default'; but still it initially shows a blank value. Is there anyway of overcoming this, or is this just the way the combo box of this type works?

Thanks
Clyde
clyde99Asked:
Who is Participating?
 
adpearceConnect With a Mentor Commented:
clyde,

Use the Combox's Items IndexOf property to select the index of the element you want.  Then just set the ItemIndex to the value returned:

ComboBox1.ItemIndex := ComboBox1.Items.IndexOf('default');

regards,
Ant.
0
 
clyde99Author Commented:
Addendum:

The code combobox1.text := 'Default';
works for all other types of combo boxes, except the CsDropDownList and unfortunately this is the type of combo box I really want to use.
0
 
edeyCommented:
You can set the comboBox's itemIndex property in the parent form's OnCreate handler.

GL
Mike
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
edeyCommented:
hmmmm....
0
 
clyde99Author Commented:
what is the hmmmm.... for edey ????
0
 
edeyCommented:
It is not generally cosidered polite to "rehash" someone else's comment as an answer


GL
Mike
0
 
clyde99Author Commented:
Mike,

Sorry. This is partly my fault. I considerd both answers to be correct, but when I looked at them adpearce was before yours, no I naturally assumed he had answered first and awarded the points.

My apologies, I should have had a closer look at the TIME.

Regards
Clyde
0
 
edeyCommented:
Hey no problem, the idea here is simply to lend a helping hand, perhaps to expect the same at a later date :)  Glad to here that you were able to find an acceptable solution :)

GL
Mike
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.