Solved

Default value for TComboBox

Posted on 1998-09-27
4
657 Views
Last Modified: 2010-04-03
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
0
Comment
Question by:gspears060598
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:binkzz
ID: 1340972
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
0
 
LVL 10

Accepted Solution

by:
viktornet earned 20 total points
ID: 1340973
You could do only ComboBox1.Text := 'Hello';

or you could do....

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

Regards,
Viktor Ivanov
0
 
LVL 4

Expert Comment

by:binkzz
ID: 1340974
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
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340975
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
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now