Link to home
Start Free TrialLog in
Avatar of gspears060598
gspears060598

asked on

Default value for TComboBox

Delphi3, NT40 - I have a TComboBox of type csDropDownList.  It has two values, All and Selected.  What I'm trying to do is to set a value in the combobox when the form opens.  I can't seem to do this.  I have tried setting the value of Text in the Object inspector.  It simply disappears when I move to another column in the object inspector. (It only does this when Type is set to csDropDownList).

I have tried programatically (On Form Activate) to set:

ComboBox.Text := 'All';
as well as
ComboBox.SelText := 'All';

Neither worked.  How do I set this value?

Thanks
Avatar of binkzz
binkzz

The default text you want in your combo list has to already exist
in the actual list seeing it is of type csdropdownlist. Therefore
make sure it has got a value, then set the itemindex property
to the value you want.

Binkzz
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
viktornet:

Read the question better next time;
the first solution you gave was something already proven
ineffective, the second was already given by me.

You were not sure if it would work as well, then why send it as
an answer?

Read the questions and the comments properly before you recogn
you can get some points. If you have a good answer, it will be
awarded, whether send as a comment or an answer. In fact, if
send as a comment rather than an answer usually gets you more
points as it is not as arrogant.

Binkzz
Why don't you stop bothering me??or is it easier for you that way......???

Here is an improvement....

OnCreate() of the form

ComboBox1.Items.Add('Hello');
ComboBox1.ItemIndex := ComboBox1.Items.IndexOf('Hello');

Regards,
Viktor Ivanov