comboBox (properties)

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
 
R

Rodrigo Ferreira

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
 
L

Lalit Bhatia

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top