When you create read only comboBox then you use two Events
- KeyPress
- KeyDown
1.KeyPress Event:-
Keypress Event arguments handled property is true.this property to all keypress object is handled and event is fire to no argument is apply all is handled by e.
e is a object that handled events.
2.KeyDown:-
In KeyDown Events all object handled by e object like Ctrl + C ,key arrows,keysdata etc are handled to this event to read only comboBox in C# this cod is very useful to this problem.
------------------------------ See this source code----------------------------------
private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}
private void comboBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys)Shortcut.CtrlC)
{
Clipboard.SetData(DataFormats.Text, comboBox1.SelectedText);
}
else if (e.KeyData == Keys.Left || e.KeyData == Keys.Right || e.KeyData == Keys.Up || e.KeyData == Keys.Down) { }
else
{
e.Handled = true;
}
}