comboBox (properties)

  • Thread starter Thread starter Claudia Fong
  • Start date Start date
C

Claudia Fong

Hi,

I would like to know if I can set a combobox properties to read-only, I
mean, usually the user can delete the items in the comboBox, but I don't
want to let the user do that.
In textbox properties, if I set to read-only, the user can't delete the
contents of the textbox.




Cheers!

Claudi
 
Use Key down event

private void comboBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)

{

if ( ( Keys ) e.KeyCode == Keys.Delete )

e.Handled = true;

}



Greetings,

Rodrigo Ferreira
 
Hi

To achieve this you can set DropDownStyle property to DropDownList. so user
can only select from combo.

otherwise u can handle keypress and keydown events to restrict delete key
and backspace key.

Regards,
Lalit Bhatia
 
Back
Top