Combo box events
-
Hi i have come across a problem using combo box events
private void comboBox1\_KeyPress(object sender, KeyPressEventArgs e) { if (Control.ModifierKeys == Keys.Delete) { imageViewer1.DeleteSelectedShape(); } } private void comboBox1\_MouseDoubleClick(object sender, MouseEventArgs e) { comboBox1.Text = "hello"; }
For some reason the above code is not fired, it is probably a simple constraint i do not know about but can anyone see why this is would not fire. Thanx in advance
-
Hi i have come across a problem using combo box events
private void comboBox1\_KeyPress(object sender, KeyPressEventArgs e) { if (Control.ModifierKeys == Keys.Delete) { imageViewer1.DeleteSelectedShape(); } } private void comboBox1\_MouseDoubleClick(object sender, MouseEventArgs e) { comboBox1.Text = "hello"; }
For some reason the above code is not fired, it is probably a simple constraint i do not know about but can anyone see why this is would not fire. Thanx in advance
I suggest you read the documentation on
Control.ModifierKeys
, your code is not OK. :)Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
I suggest you read the documentation on
Control.ModifierKeys
, your code is not OK. :)Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Hi i have come across a problem using combo box events
private void comboBox1\_KeyPress(object sender, KeyPressEventArgs e) { if (Control.ModifierKeys == Keys.Delete) { imageViewer1.DeleteSelectedShape(); } } private void comboBox1\_MouseDoubleClick(object sender, MouseEventArgs e) { comboBox1.Text = "hello"; }
For some reason the above code is not fired, it is probably a simple constraint i do not know about but can anyone see why this is would not fire. Thanx in advance
Just found a solution so thought i would post it : Most controls don,t fire delete on key press so override command key pressed and check value in keypress
// Override cmd key press
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{if (keyData == Keys.Delete) OnKeyPress(new KeyPressEventArgs((Char)Keys.Delete)); return base.ProcessCmdKey(ref msg, keyData); } private void Form1\_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (Char)Keys.Delete) { imageViewer1.DeleteSelectedShape(); } }
Thanx for the help George
-
Just found a solution so thought i would post it : Most controls don,t fire delete on key press so override command key pressed and check value in keypress
// Override cmd key press
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{if (keyData == Keys.Delete) OnKeyPress(new KeyPressEventArgs((Char)Keys.Delete)); return base.ProcessCmdKey(ref msg, keyData); } private void Form1\_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (Char)Keys.Delete) { imageViewer1.DeleteSelectedShape(); } }
Thanx for the help George
sounds fair. Some keys are used to support editing, unless you tell the control otherwise. :)
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Hi i have come across a problem using combo box events
private void comboBox1\_KeyPress(object sender, KeyPressEventArgs e) { if (Control.ModifierKeys == Keys.Delete) { imageViewer1.DeleteSelectedShape(); } } private void comboBox1\_MouseDoubleClick(object sender, MouseEventArgs e) { comboBox1.Text = "hello"; }
For some reason the above code is not fired, it is probably a simple constraint i do not know about but can anyone see why this is would not fire. Thanx in advance