繁体   English   中英

如何在DataGridView的KeyPress事件上将焦点设置在TextBox上(以前的焦点在此TextBox上)

[英]How to set focus on TextBox (previously the focus was on this TextBox) on KeyPress event of DataGridView

这是我的代码:

private void gv_old_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == 27)
    {
        gv_old.Visible = false;
        // And want focus on that TextBox
    }
}

我想要的是将焦点放在DataGridView上,将焦点放在先前的TextBox上。

假设您在下面有一个文本框:

TextBox textbox1;

您可以像这样将焦点设置在文本框中,

textbox1.focus();

试试这个:

yourTextBox.Focus();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM