Solved

Default value for TComboBox

Posted on 1998-09-27
4
660 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Memory leak using records in a TVirtualStringTree 11 109
IExtractImage Delphi 14 201
select query - oracle 16 92
SUM 2 INTEGER ARRAYS INTO 1 10 93
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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