I'd like to disable the right arrow when I'm using the ComboBox control in the Compact Framework 3.5.
I already tried that :
private void Combo_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Right))
{
TxtPass.Focus();
return;
}
}
but the ComboBox value change.
I looked the 2 methods described on this page : http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/F8F2FE7D-A908-4AAF-BD5C-627529BB9805
But the 2 methods doesn't work for the compact framework. (the properties don't exist).
Does someone has a good idea?
regards
Edit
I just find the solution
private void Combo_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Right))
{
TxtPass.Focus();
e.Handled = true;
return;
}
}
thank you for your answer
This is old school, but works very well.
[Disclaimer: I do not have VS2008 installed where I am now (at home), so I can not verify that the ComboBox item SelectedIndex is part of the Compact Framework. If it is not, you'd have to find some other technique to parse through your ComboBox items.]
int comboIndex; // Add 1 variable
private void Combo_KeyDown(object sender, KeyEventArgs e)
{
if (comboIndex != comboBox1.SelectedIndex)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Right))
{
TxtPass.Focus();
comboBox1.SelectedIndex = comboIndex;
return;
}
}
comboIndex = comboBox1.SelectedIndex; // Don't forget to set this!
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With