Disabling combo-box text editing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I'd like to disable the text-editing for a drop-down combo box (without disabling the whole control). How do I do this

I've tried intercepting the KeyPress message, which worked for a text box but does not work for a combo-box. I've also tried overriding the ProcessKeyEventArgs, ProcessKeyMessage, and ProcessKeyPreview methods, but to no avail. Help

Thanks in advance

Alfredo
 
Fredo said:
I'd like to disable the text-editing for a drop-down combo box
(without disabling the whole control). How do I do this?

Have you tried setting the DropDownStyle to ComboBoxStyle.DropDownList?
 
No, the combo-box style needs to be a regular drop-down, and the edit box must be disabled only under certain circumstances.
 
DropDownStyle.DropDownList is a "regular" combobox with a non-editable text region. It is also assignable at runtime.
 
Fredo said:
No, the combo-box style needs to be a regular drop-down, and the edit
box must be disabled only under certain circumstances.

So set the combo style to DropDownList only under those circumstances,
and have it as DropDown for the rest of the time. If that doesn't work
for you, please state *exactly* in what way it doesn't.
 
Thanks for the responses

I thought about doing that, and it would be a good solution except for one thing: a drop-down-list combo box does not allow you to select part (or all) of the selected item and copy it into the clipboard using Ctrl-C or Ctrl-Insert, while a regular drop-down does (much like in a text box). But if I disallow text entry into a drop-down I'd still like to be able to copy the selection (or part of it) into the clipboard, in a sense behaving like a read-only text box
 
Back
Top