Handling arrow key events on a winform textbox without overriding

坚强是说给别人听的谎言 提交于 2019-12-05 14:16:25
Jens

I hope i haven't missunderstood you, but is this a solution:

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Down)
    {
         // Place logic for textbox here
    }
}

I'd use a KeyDown event on the form and then compare the keycode with the Keys.Down keycode

Not working

see here: Up, Down, Left and Right arrow keys do not trigger KeyDown event

I may not be understanding your question entirely, but wouldn't an approach like this work?

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    comboBox1.Text = //results of your matching algorithm.
}

private void textBox1_Validated(object sender, EventArgs e)
{
    textBox1.Text = (string) comboBox1.Text;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!