uneditable comboBox

  • Thread starter Thread starter justin.creasy
  • Start date Start date
J

justin.creasy

I was wondering if anyone knew how to make a comboBox that cannot be
edited, but works in every other way. I have tried setting the
<comboBox name>.Enabled to false, but then I can't use the comboBox. I
merely want a way to have a comboBox with multiple items that can be
choosen from the drop down, but not allow text to be entered. Another
idea I had was to capture every keystroke, but that's a lot of
computing and my UI is already pretty intense. Any ideas would be
greatly appreciated.
 
I was wondering if anyone knew how to make a comboBox that cannot be
edited, but works in every other way. I have tried setting the
<comboBox name>.Enabled to false, but then I can't use the comboBox. I
merely want a way to have a comboBox with multiple items that can be
choosen from the drop down, but not allow text to be entered. Another
idea I had was to capture every keystroke, but that's a lot of
computing and my UI is already pretty intense. Any ideas would be
greatly appreciated.

Try setting <comboBox name>.DropDownStyle = ComboBoxStyle.DropDownList
 
Daniel O'Connell said:
[non-editable ComboBox]

Try setting <comboBox name>.DropDownStyle =
ComboBoxStyle.DropDownList

Alternatively, if you want the *application* to be able to put
non-standard values in the box, but not the user, you need to override
various events, such as KeyDown, and do "e.Handled = true" so that the
event won't propagate. Make sure you handle things like Ctrl+V for
pasting text.

P.
 
Thanks, I had thought of catching the events. I did not want to do that
b/c of how much I already have going on in my UI. Daniel's idea of just
setting the DropDownStyle to DropDownList worked perfectly. It makes
sense now that I think about it, but I still don't know why there isn't
a ReadOnly attribute. Oh well, thanks a lot!
 
Back
Top