How to remove TComboBox selection?

I have an application to maintain developed in BDS2006. Now migrated
to XE5.
It contains a configuration window with multiple tabs and here are a
number of controls for parameter selection. One type of component is
causing problems because in some instances its content is selected
causing the text to get a dark blue background. The selection cannot
be removed except by manually going to the control and putting the
cursor on the entry. Then it is deselected and the text can be read
properly. But some controls are enabled only depending on the setting
of another control, so if that is in the state that disables the entry
box then the selection won't go away at all.

The component is a descendant of TComboBox called TNumComboBox by the
author and the changes from the standard TComboBox is shown here:
{code}
type
  TNumComboBox = class(TComboBox)
  protected
    procedure Change; override;
  end;

procedure Register;

implementation
function StrToFloatUS(sVal: string): Double;
{This function converts a string to float using the decimal separator
...
If the string contains illegal characters they are removed first.
If the conversion results in an exception then return 0}
var
  c: char;
  i: integer;
  Fmt: TFormatSettings;
begin
  {$IF CompilerVersion >= 26} {Delphi XE5..}
    Fmt := TFormatSettings.Create;
  {$IFEND}
  Fmt.DecimalSeparator := '.';
  {Scan string for illegal characters, replace comma with . etc}
  sVal := Trim(LowerCase(sVal));
  for i := Length(sVal) downto 1 do
    if sVal[i] = ',' then
      sVal[i] := '.';
  try
    if sVal = '' then
      Result := 0
    else
      Result := StrToFloat(sVal, Fmt);
  except
    Result := 0;
  end;
end;

procedure TNumCombobox.Change;
begin
  Inherited Change;
  try
    StrToFloatUS(Text);
  except
    on EConvertError do
    begin
      Text := '';
    end;
  end;
end;

procedure Register;
begin
  RegisterComponents('MyCustomCmp', [TNumComboBox]);
end;
{code}

In the main code the comboboxes get filled from the forms designer and
there are also places where its text property is being set by direct
writing in code to the control. This happens when some data files are
loaded for example.
The enabling and disabling of the TNumCombobox is done as follows
(cbxForwSolver is a regular TComboBox whereas cbxForwCGIter and
cbxForwCGResid are TNumComboBox objects):
{code}
procedure TfrmSettings.cbxForwSolverChange(Sender: TObject);
begin
    if cbxForwSolver.ItemIndex = 0 then begin
        cbxForwCGIter.Enabled := false;
        cbxForwCGResid.Enabled := false;
    end else begin
        cbxForwCGIter.Enabled := true;
        cbxForwCGResid.Enabled := true;
    end;
end;
{code}

Any idea how I could deselct the text in the TNumComboBox in code?


---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/8/2015 6:11:23 AM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

20 Replies
570 Views

Similar Articles

[PageSpeed] 11

I might add that I checked the various properties and methods of the
TComboBox class and especially ClearSelection looked promising by the
name at least. However, what it does is setting ItemIndex = -1 and the
Text property to an empty string, not exactly what I need...
I just want to remove the selection coloring just as if I had placed
the cursor at the end of the text in the box or similar.
But doing this in code....

---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/8/2015 7:39:05 AM
And setting SelStart only works if the control has focus, which of
course is not possible for a disabled control...


---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/8/2015 7:45:21 AM
Bo Berglund wrote:

> I have an application to maintain developed in BDS2006. Now migrated
> to XE5.
> It contains a configuration window with multiple tabs and here are a
> number of controls for parameter selection. One type of component is
> causing problems because in some instances its content is selected
> causing the text to get a dark blue background. The selection cannot
> be removed except by manually going to the control and putting the
> cursor on the entry. Then it is deselected and the text can be read
> properly. But some controls are enabled only depending on the setting
> of another control, so if that is in the state that disables the entry
> box then the selection won't go away at all.

Is this perhaps the ActiveControl of the form? Make sure you set this
form property to a control that will not be disabled during form load.
If the form is shown modally, set the PopupMode property to pmAuto.


-- 
Peter Below (TeamB)
0
Peter
8/8/2015 10:32:19 AM
On Sat, 8 Aug 2015 03:32:19 -0700, Peter Below <none@address.invalid>
wrote:

>Is this perhaps the ActiveControl of the form? Make sure you set this
>form property to a control that will not be disabled during form load.

The configuration form has a number of tabs and the form's
ActiveControl property is empty as far as I can see.
I have never used this property before, what good is it?
I tried to set its value to the Ok button just as a test, but there
was no change in behaviour.

>If the form is shown modally, set the PopupMode property to pmAuto.
The form is shown as follows:
{code}
procedure TfrmMain.mitCRPSettingsClick(Sender: TObject);
begin
  frmSettings.GetLagrangeDamp0; //Reads avalues in some controls into
variables
  frmSettings.Show;
end;
{code}
As you can see it is not shown modally at all (which is a usability
problem all by itself). And the PopUpMode property of the form is
pmNone.

Note that there are several controls of the same kind in the form but
not all of them does this. In fact there is a control on the main form
(beside the tool bar) which is rather seldom used but this too shows a
selected text when the application starts running and it is not
possible to get rid of the selection and hence it sticks out even
though the combo is mostly disabled.


---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/8/2015 12:56:05 PM
Bo Berglund wrote:

> On Sat, 8 Aug 2015 03:32:19 -0700, Peter Below <none@address.invalid>
> wrote:
> 
> > Is this perhaps the ActiveControl of the form? Make sure you set
> > this form property to a control that will not be disabled during
> > form load.
> 
> The configuration form has a number of tabs and the form's
> ActiveControl property is empty as far as I can see.
> I have never used this property before, what good is it?

It defines which control will get the focus when the form is shown the
first time. If you leave it empty at design-time then the first
focusable control in tab order will get the focus. Once the form is up
this property gives you the control currently with focus, and you can
set it to move the focus in code.
 
> I tried to set its value to the Ok button just as a test, but there
> was no change in behaviour.
> 
> > If the form is shown modally, set the PopupMode property to pmAuto.
> The form is shown as follows:
> {code}
> procedure TfrmMain.mitCRPSettingsClick(Sender: TObject);
> begin
>   frmSettings.GetLagrangeDamp0; //Reads avalues in some controls into
> variables
>   frmSettings.Show;
> end;
> {code}
> As you can see it is not shown modally at all (which is a usability
> problem all by itself). And the PopUpMode property of the form is
> pmNone.
> 
> Note that there are several controls of the same kind in the form but
> not all of them does this. In fact there is a control on the main form
> (beside the tool bar) which is rather seldom used but this too shows a
> selected text when the application starts running and it is not
> possible to get rid of the selection and hence it sticks out even
> though the combo is mostly disabled.

It can be problematic if you change the enabled state of controls
during the form load, or when the control does not have a handle yet
(can happen for controls on tabsheets other than the active one, for
example). Try to call the control's HandleNeeded function before you
modify its content or state in code, perhaps that fixes the problem.

It seems to be something you only run into with combo boxes having the
csDropdown style (= editable by the user). I have never seen it in my
own applications, but I practically only use csDropdownList comboboxes.


-- 
Peter Below (TeamB)
0
Peter
8/8/2015 2:06:15 PM
You didn't say if the user fills in these comboboxes by picking on the dropdown list or he types in a number in the combobox.

If he just fills them in by picking from the list then you should set the Style property to csDropdownList. Then the combobox text never gets selected or turns blue.
0
Douglas
8/8/2015 2:45:21 PM
> {quote:title=Bo Berglund wrote:}{quote}

I'm not sure about your scenario or when you want to remove the selection in the edit child control
of the ComboBox, but normally sending a CB_SETEDITSEL message to the ComboBox is the way to do it:

SendMessage(SomeComboBox.Handle, CB_SETEDITSEL, 0, 0);

Normally setting Enabled to False will also remove the selection.

If sending a CB_SETEDITSEL message doesn't work in your scenario, then you could instead try toggling
the Enabled state, possibly a couple of times if needed.

For example, if the ComboBox is Enabled:
SomeComboBox.Enabled := False; //Removes the selection
SomeComboBox.Enabled := True; //Enabled and still no selection

The toggling isn't noticeable.

Remove the selection wherever you feel it's needed - in an OnChange or OnEnter event handler, for instance.
--
C-H
0
Carl
8/8/2015 4:29:38 PM
> {quote:title=Bo Berglund wrote:}{quote}
><snip>
> Any idea how I could deselct the text in the TNumComboBox in code?

I'm not sure about your scenario or when you want to remove the selection in the edit child control
of the ComboBox, but normally sending a CB_SETEDITSEL message to the ComboBox is the way to do it:

SendMessage(SomeComboBox.Handle, CB_SETEDITSEL, 0, 0);

Normally setting Enabled to False will also remove the selection.

If sending a CB_SETEDITSEL message doesn't work in your scenario, then you could instead try toggling
the Enabled state, possibly a couple of times if needed.

For example, if the ComboBox is Enabled:
SomeComboBox.Enabled := False; //Removes the selection
SomeComboBox.Enabled := True; //Enabled and still no selection

The toggling isn't noticeable.

Remove the selection wherever you feel it's needed - in an OnChange or OnEnter event handler, for instance.
--
C-H
0
Carl
8/8/2015 4:36:32 PM
> {quote:title=Carl-Henrik Nilsson wrote:}{quote}
> Remove the selection wherever you feel it's needed - in an OnChange or OnEnter event handler, for instance.

Oops, That doesn't work. Need to delay by posting a custom message in an OnChange or OnEnter event handler:

{code}
const
  WM_DESELECT = WM_APP + 1;

TForm1 = class(TForm)
  <snip>
private
  procedure WMDeSelect(var Msg: TMessage); message WM_DESELECT;
end;

procedure TForm1.WMDeSelect(var Msg: TMessage);
begin
  SendMessage(SomeComboBox.Handle, CB_SETEDITSEL, 0, 0);
end;

procedure TForm1.SomeComboBoxChange(Sender: TObject);
begin
  PostMessage(SomeComboBox, WM_DESELECT, 0, 0);
end;

procedure TForm1.SomeComboBoxEnter(Sender: TObject);
begin
  PostMessage(Handle, WM_DESELECT, 0, 0);
end;
{code}
--
C-H
0
Carl
8/8/2015 6:12:41 PM
> {quote:title=Carl-Henrik Nilsson wrote:}{quote}
> Remove the selection wherever you feel it's needed - in an OnChange or OnEnter event handler, for instance.

Oops, That doesn't work. Need to delay by posting a custom message in an OnChange or OnEnter event handler:

{code}
const
  WM_DESELECT = WM_APP + 1;

TForm1 = class(TForm)
  <snip>
private
  procedure WMDeSelect(var Msg: TMessage); message WM_DESELECT;
end;

procedure TForm1.WMDeSelect(var Msg: TMessage);
begin
  SendMessage(SomeComboBox.Handle, CB_SETEDITSEL, 0, 0);
end;

procedure TForm1.SomeComboBoxChange(Sender: TObject);
begin
  PostMessage(Handle, WM_DESELECT, 0, 0);
end;

procedure TForm1.SomeComboBoxEnter(Sender: TObject);
begin
  PostMessage(Handle, WM_DESELECT, 0, 0);
end;
{code}

(This forum is a real pain to use)
--
C-H
0
Carl
8/8/2015 6:22:52 PM
On Sat, 8 Aug 2015 07:45:21 -0700, Douglas Rudd <> wrote:

>You didn't say if the user fills in these comboboxes by picking on the dropdown list or he types in a number in the combobox.

I am not sure, normally I think a number is chosen from the list. But
it may also be the case that in some circumstances a new value is
typed in.
I'll have to ask the application guys about that. I don't expect to
get a reply until Monday though...

>If he just fills them in by picking from the list then you should set the Style property to csDropdownList. Then the combobox text never gets selected or turns blue.

Right, that is how I usually program combo boxes. But this is anoter
guy's creation and I am just maintaining it (upgrading to XE5 and
introducing Unicode text for internationalization).


---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/8/2015 7:20:13 PM
On Sat, 8 Aug 2015 09:36:32 -0700, Carl-Henrik Nilsson <> wrote:

>> {quote:title=Bo Berglund wrote:}{quote}
>><snip>
>> Any idea how I could deselct the text in the TNumComboBox in code?
>
>I'm not sure about your scenario or when you want to remove the 
>selection in the edit child control of the ComboBox, 

When the form is shown for the first time after starting the
application some of the TNumComboBox components show their text as
selected (dark blue background). This can be removed manually for
controls that are enabled by setting the cursor in the box with the
mouse. But this is not optimal behaviour, I would rather have these
controls show unselected text all the time.
And any such control which is not enabled cannot be fixed manually
because the cursor cannot be set on these.

>but normally sending a CB_SETEDITSEL message to the ComboBox is the way to do it:
>SendMessage(SomeComboBox.Handle, CB_SETEDITSEL, 0, 0);

I don't know how to do this...
I tried adding this to the button event function shown below:
{code}
  SendMessage(cbxDepthFactor.Handle, CB_SETEDITSEL, 0, 0);
{code}
But this would not compile because:
[dcc32 Error] FormSettings.pas(301): E2003 Undeclared identifier:
'CB_SETEDITSEL'

>Normally setting Enabled to False will also remove the selection.
Well, most of the problem controls are set enabled=false in the
designer. They are only enabled in certain cases of other settings.

>
>If sending a CB_SETEDITSEL message doesn't work in your scenario, then you could instead try toggling
>the Enabled state, possibly a couple of times if needed.
>
>For example, if the ComboBox is Enabled:
>SomeComboBox.Enabled := False; //Removes the selection
>SomeComboBox.Enabled := True; //Enabled and still no selection
>
>The toggling isn't noticeable.
>

I tested your suggestion by adding a button on the form and putting
this on the buttonclick event:
{code}
procedure TfrmSettings.Button1Click(Sender: TObject);
var
  State1, State2: boolean;
begin
  State1 := cbxDepthFactor.Enabled;
  State2 := cbxForwCGIter.Enabled;
  cbxDepthFactor.Enabled := true;
  cbxForwCGIter.Enabled := true;
  Sleep(5);
  cbxDepthFactor.Enabled := State1;
  cbxForwCGIter.Enabled := State2;
end;
{code}
But nothing at all happens when I click the button...

>Remove the selection wherever you feel it's needed - in an OnChange or OnEnter event handler, for instance.
???
My problem is that I don't know how to remove the selection in the
first place....
The sendmessage did not work because the compiler did not like it...

---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/8/2015 7:47:36 PM
> {quote:title=Bo Berglund wrote:}{quote}
> My problem is that I don't know how to remove the selection in the
> first place....
> The sendmessage did not work because the compiler did not like it...

CB_SETEDITSEL is declared in Winapi.Messages, so add it to uses.

Try posting a WM_DESELECT custom message in a ComboBox OnChange or OnEnter event handler.
Try also posting such a message in an OnShow event handler for the form:

{code}
const
  WM_DESELECT = WM_APP + 1;

TForm1 = class(TForm)
  <snip>
private
  procedure WMDeSelect(var Msg: TMessage); message WM_DESELECT;
end;


procedure TForm1.WMDeSelect(var Msg: TMessage);
var
  L: Integer;
begin
  L := Length(SomeComboBox.Text);
  SendMessage(SomeComboBox.Handle, CB_SETEDITSEL, 0, MakeLParam(L, L));
end;

procedure TForm1.SomeComboBoxChange(Sender: TObject);
begin
  PostMessage(Handle, WM_DESELECT, 0, 0);
end;

procedure TForm1.SomeComboBoxEnter(Sender: TObject);
begin
  PostMessage(Handle, WM_DESELECT, 0, 0);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  PostMessage(Handle, WM_DESELECT, 0, 0);
end;
{code}
--
C-H
0
Carl
8/8/2015 9:33:15 PM
On Sat, 8 Aug 2015 14:33:15 -0700, Carl-Henrik Nilsson <> wrote:

>> {quote:title=Bo Berglund wrote:}{quote}
>> My problem is that I don't know how to remove the selection in the
>> first place....
>> The sendmessage did not work because the compiler did not like it...
>
>CB_SETEDITSEL is declared in Winapi.Messages, so add it to uses.

Thanks,
that uses file fixed the compilation error and now I can use the
button on the form to deselect the text in the combobox. :)


>Try posting a WM_DESELECT custom message in a ComboBox OnChange or OnEnter event handler.
>Try also posting such a message in an OnShow event handler for the form:

Why do I need to do that? Isn't the Sendmessage solution good enough?
If I put the selection clearing into the OnShow event procedure for
the form then I should be able to get rid of the selections, right?
I'll try and report back here.


---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/8/2015 9:51:44 PM
On Sat, 8 Aug 2015 14:51:44 -0700, Bo Berglund
<bo.berglund@nospam.com> wrote:

>>CB_SETEDITSEL is declared in Winapi.Messages, so add it to uses.
>
>Thanks,
>that uses file fixed the compilation error and now I can use the
>button on the form to deselect the text in the combobox. :)
>
>
>If I put the selection clearing into the OnShow event procedure for
>the form then I should be able to get rid of the selections, right?
>I'll try and report back here.
>
I have done so now and it seems to work fine. This is how I did it for
these two controles:
{code}
procedure TfrmSettings.FormShow(Sender: TObject);
begin
  SendMessage(cbxDepthFactor.Handle, CB_SETEDITSEL, 0, 0);
  SendMessage(cbxForwCGIter.Handle, CB_SETEDITSEL, 0, 0);
end;
{code}

Now I would like to have a way to iterate through all TNumComboBox
components and do the same to them all, preferably in some kind of
loop so I don't have to list all the controls and keep track of the
names if new items are added.
Any ideas how that could be done inside the form's onshow event?
Something like:
{code}
procedure TfrmSettings.FormShow(Sender: TObject);
var
  NCB: TNumComboBox;
  i: integer;
begin
  for i := 0 to <Number_of_Components> -1 do
  begin
    if Component[i] is TNumComboBox then
       SendMessage(TNumComboBox(Component[i]).Handle, CB_SETEDITSEL,
0, 0);
  end;
end;
{code}

Is there some way to iterate through and find all TNumComboBoxes on a
form?

---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/8/2015 10:14:01 PM
On Sat, 8 Aug 2015 15:14:01 -0700, Bo Berglund
<bo.berglund@nospam.com> wrote:


>Is there some way to iterate through and find all TNumComboBoxes on a
>form?

Yes, this works fine for all of the boxes in the form:
{code}
procedure TfrmSettings.FormShow(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to ComponentCount -1 do
  begin
    if Components[i] is TNumComboBox then
       SendMessage(TNumComboBox(Components[i]).Handle,
CB_SETEDITSEL,0, 0);
  end;
end;
{code}

Thanks again for your suggestions, I think the problem is now solved
(on the main form and the settings form at least)..


---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/8/2015 10:26:24 PM
> {quote:title=Bo Berglund wrote:}{quote}
> On Sat, 8 Aug 2015 14:51:44 -0700, Bo Berglund
> <bo.berglund@nospam.com> wrote:
> 
> >>CB_SETEDITSEL is declared in Winapi.Messages, so add it to uses.
> >
> >Thanks,
> >that uses file fixed the compilation error and now I can use the
> >button on the form to deselect the text in the combobox. :)
> >
> >
> >If I put the selection clearing into the OnShow event procedure for
> >the form then I should be able to get rid of the selections, right?
> >I'll try and report back here.
> >
> I have done so now and it seems to work fine. This is how I did it for
> these two controles:
> {code}
> procedure TfrmSettings.FormShow(Sender: TObject);
> begin
>   SendMessage(cbxDepthFactor.Handle, CB_SETEDITSEL, 0, 0);
>   SendMessage(cbxForwCGIter.Handle, CB_SETEDITSEL, 0, 0);
> end;
> {code}

Well, there you go. Posting the WM_DESELECT message was necessary had you used the other event handlers - puts the handling
last in the message queue.

> Now I would like to have a way to iterate through all TNumComboBox
> components and do the same to them all, preferably in some kind of
> loop so I don't have to list all the controls and keep track of the
> names if new items are added.
> Any ideas how that could be done inside the form's onshow event?
> Something like:
> {code}
> procedure TfrmSettings.FormShow(Sender: TObject);
> var
>   NCB: TNumComboBox;
>   i: integer;
> begin
>   for i := 0 to <Number_of_Components> -1 do
>   begin
>     if Component[i] is TNumComboBox then
>        SendMessage(TNumComboBox(Component[i]).Handle, CB_SETEDITSEL,
> 0, 0);
>   end;
> end;
> {code}
> 
> Is there some way to iterate through and find all TNumComboBoxes on a
> form?

{code}
procedure TfrmSettings.FormShow(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to ComponentCount - 1 do
  begin
    if Components[i] is TNumComboBox then
       SendMessage((Components[i] as TNumComboBox).Handle, CB_SETEDITSEL, 0, 0);
  end;
end;
{code}
--
C-H
0
Carl
8/8/2015 10:44:37 PM
Bo Berglund wrote:

> On Sat, 8 Aug 2015 03:32:19 -0700, Peter Below <none@address.invalid>
> wrote:
> 
> > Is this perhaps the ActiveControl of the form? Make sure you set
> > this form property to a control that will not be disabled during
> > form load.
> 
> The configuration form has a number of tabs and the form's
> ActiveControl property is empty as far as I can see.
> I have never used this property before, what good is it?

It defines which control will get the focus when the form is shown the
first time. If you leave it empty at design-time then the first
focusable control in tab order will get the focus. Once the form is up
this property gives you the control currently with focus, and you can
set it to move the focus in code.
 
> I tried to set its value to the Ok button just as a test, but there
> was no change in behaviour.
> 
> > If the form is shown modally, set the PopupMode property to pmAuto.
> The form is shown as follows:
> {code}
> procedure TfrmMain.mitCRPSettingsClick(Sender: TObject);
> begin
>   frmSettings.GetLagrangeDamp0; //Reads avalues in some controls into
> variables
>   frmSettings.Show;
> end;
> {code}
> As you can see it is not shown modally at all (which is a usability
> problem all by itself). And the PopUpMode property of the form is
> pmNone.
> 
> Note that there are several controls of the same kind in the form but
> not all of them does this. In fact there is a control on the main form
> (beside the tool bar) which is rather seldom used but this too shows a
> selected text when the application starts running and it is not
> possible to get rid of the selection and hence it sticks out even
> though the combo is mostly disabled.

It can be problematic if you change the enabled state of controls
during the form load, or when the control does not have a handle yet
(can happen for controls on tabsheets other than the active one, for
example). Try to call the control's HandleNeeded function before you
modify its content or state in code, perhaps that fixes the problem.

It seems to be something you only run into with combo boxes having the
csDropdown style (= editable by the user). I have never seen it in my
own applications, but I practically only use csDropdownList comboboxes.


-- 
Peter Below (TeamB)
0
Peter
8/10/2015 7:58:49 AM
> {quote:title=Peter Below wrote:}{quote}
> It seems to be something you only run into with combo boxes having the
> csDropdown style (= editable by the user). I have never seen it in my
> own applications, but I practically only use csDropdownList comboboxes.

I've never seen it before either, but I can reproduse it with XE5 on Win7 now that I'm sure about what happens and when:

- Drop a TComboBox on a form
- Set the syle to csDropDown
- Add some Items
- Set ItemIndex to an Item
- Set Enabled to False

Run, and the ComboBox turns up with blackish text against a blue background - hard to read.
--
C-H
0
Carl
8/10/2015 11:28:06 AM
On Mon, 10 Aug 2015 04:28:06 -0700, Carl-Henrik Nilsson <> wrote:

>> {quote:title=Peter Below wrote:}{quote}
>> It seems to be something you only run into with combo boxes having the
>> csDropdown style (= editable by the user). I have never seen it in my
>> own applications, but I practically only use csDropdownList comboboxes.
>
>I've never seen it before either, but I can reproduse it with XE5 on Win7 now that I'm sure about what happens and when:
>
>- Drop a TComboBox on a form
>- Set the syle to csDropDown
>- Add some Items
>- Set ItemIndex to an Item
>- Set Enabled to False
>
>Run, and the ComboBox turns up with blackish text against a blue background - hard to read.

And your suggested way to deselect the text in the disabled CB works!
:)

---
Bo Berglund
Sweden & Texas
Newsreader: Forte Free Agent 1.92/32.572
0
Bo
8/10/2015 8:06:37 PM
Reply:

Web resources about - How to remove TComboBox selection? - embarcadero.delphi.general

Selection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Canberra Raiders coach Ricky Stuart faces 'welcome' selection headache
It's a headache Ricky Stuart, or the Raiders for that matter haven't had for a long time - the prospect of telling deserved players they won't ...

Bombers belt Blues, Carlton coach Bolton defends young midfield selections
Match delivers a melee but it's only February, as field umpires welcome first female and Ikon Park relives the good old days. Carlton coach Brendon ...

Carlton erred in on-field selections against Essendon
Dismal performance by the undermanned Blues last Sunday raised eyebrows all the way to AFL head office.

Canberra Raiders coach Ricky Stuart faces 'welcome' selection headache
It's a headache Ricky Stuart, or the Raiders for that matter haven't had for a long time - the prospect of telling deserved players they won't ...

"The scenario that the left would most favor and the right most fears would be the selection of a barrier-breaking ...
"The name most frequently discussed in this situation is Attorney General Loretta Lynch, who would be the first black woman to serve on the court. ...

AP PHOTOS: Editor selections from the past week in Asia
Nearly 3,000 delegates from across China gathered to kick off the annual National People's Congress in Beijing's Great Hall of the People this ...

Watchog Or Lapdog? Emails Show Hillary Had A Hand In Inspector General Selection
Watchog Or Lapdog? Emails Show Hillary Had A Hand In Inspector General Selection

Bodega Bagel Taste Test: Sietsema Reviews a Selection of Bodega Bagels
Eater's critic makes notes on a variety of bagels from local bodegas. Not all bodega bagels are created equal. There's an estimated 12,000 independently-owned ...

Chrissy Teigen Chose Her Baby's Sex During IVF: Here's What You Need to Know About Gender Selection
Chrissy Teigen Chose Her Baby's Sex During IVF: Here's What You Need to Know About Gender Selection

Resources last updated: 3/7/2016 12:00:02 PM