Board index » delphi » Setting text in the edit area of a combo box

Setting text in the edit area of a combo box

Under "Combo boxes", Delphi help says:

"Use csdropdownlist style to make the edit region read only. The user
can't edit an item or type in a new item..."

This seems to imply that I should be able to place text into the edit
area at design time, but that the text would then not be editable
(like the combo box I see, for example, in the "open file" dialog for
the drop down list of file types). However, I can't find a way to get
text into the area (except with one of the other styles, when the text
is then editable, which I don't want, as I just want it to show a
description of what's in the drop down list).

Does anyone know how to do this?

 

Re:Setting text in the edit area of a combo box


On 1 Mar 2003 01:54:35 -0800, beete...@aol.com (John Beeteson) wrote:

Quote
>Under "Combo boxes", Delphi help says:

>"Use csdropdownlist style to make the edit region read only. The user
>can't edit an item or type in a new item..."

It also says that with this style the Text property is ignored

Quote

>This seems to imply that I should be able to place text into the edit
>area at design time, but that the text would then not be editable
>(like the combo box I see, for example, in the "open file" dialog for
>the drop down list of file types).

Finally I've worked out what   "open file" dialog    you are referring
to - it is actually the TFilterComboBox

If you really want that effect, and I can see some advantages in it,
why not simply use a TFilterComboBox

- you can add a list at design time
- admittedly a bit of a hack

The other alternative looks like creating your own TCustomComboBox
descendant
- it looks as if FSaveIndex := -1 in the Create is the culprit

I assume you are concerned with the design time appearance, otherwise
there is no problem overriding the Create and setting the ListIndex

Quote
>However, I can't find a way to get
>text into the area (except with one of the other styles, when the text
>is then editable, which I don't want, as I just want it to show a
>description of what's in the drop down list).

>Does anyone know how to do this?

Re:Setting text in the edit area of a combo box


Yes, that's nice. Using the filter property I managed to get almost
exactly what I wanted - thanks for the suggestion. There is just one
thing I'd like to change if possible. When an item from the drop down
list is selected, it is remembered by the control and presented as the
text the next time the control is shown. I'd rather show my own choice
of text, but I can't seem to get it to do this - any ideas?

Anyway, it works well enough for what I want, thanks again.

Re:Setting text in the edit area of a combo box


On 1 Mar 2003 12:14:16 -0800, beete...@aol.com (John Beeteson) wrote:

Quote
>Yes, that's nice. Using the filter property I managed to get almost
>exactly what I wanted - thanks for the suggestion. There is just one
>thing I'd like to change if possible. When an item from the drop down
>list is selected, it is remembered by the control and presented as the
>text the next time the control is shown. I'd rather show my own choice
>of text, but I can't seem to get it to do this - any ideas?

>Anyway, it works well enough for what I want, thanks again.

Could you give an example ?

I think the answer might involve tinkering with the Items
- or the ItemIndex

Re:Setting text in the edit area of a combo box


Quote
Bounce_It_je...@iss.u-net.com_.bin (J French) wrote in message <news:3e61e040.3051572@news.u-net.com>...
> On 1 Mar 2003 12:14:16 -0800, beete...@aol.com (John Beeteson) wrote:

> >Yes, that's nice. Using the filter property I managed to get almost
> >exactly what I wanted - thanks for the suggestion. There is just one
> >thing I'd like to change if possible. When an item from the drop down
> >list is selected, it is remembered by the control and presented as the
> >text the next time the control is shown. I'd rather show my own choice
> >of text, but I can't seem to get it to do this - any ideas?

> >Anyway, it works well enough for what I want, thanks again.
> Could you give an example ?

> I think the answer might involve tinkering with the Items
> - or the ItemIndex

You are quite right, setting itemIndex to 0 does the job. I'm afraid
that I tend to limit myself to looking at the property list in the
object inspector, instead of checking out all the propoerties of the
control. Thanks once again, I now have just what I want.

Re:Setting text in the edit area of a combo box


On 3 Mar 2003 01:04:45 -0800, beete...@aol.com (John Beeteson) wrote:

<snip>

Quote
>> I think the answer might involve tinkering with the Items
>> - or the ItemIndex

>You are quite right, setting itemIndex to 0 does the job. I'm afraid
>that I tend to limit myself to looking at the property list in the
>object inspector, instead of checking out all the propoerties of the
>control. Thanks once again, I now have just what I want.

Yes, I find that the only way is to prowl through the Help system, and
drill into the libraries

Other Threads