Solved

Default value for TComboBox

Posted on 1998-09-27
4
683 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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