【问题标题】:I am trying to make the insertion point default to the first text box after a button is pressed我试图在按下按钮后将插入点默认为第一个文本框
【发布时间】:2014-03-05 09:14:07
【问题描述】:

我目前有一个 winforms 应用程序,它有 6 个按钮,按下后它们会根据需要创建或删除文本框 IE:姓名、日期、年龄等。

每个按钮都是不同的问题,但是当我按下按钮时,它会自动将插入点(类型指示器)放在第一个文本框中。

这是我的 button1_Click 方法

    private void button1_Click(object sender, EventArgs e)
    {
        label2.Visible = false;
        label3.Visible = false;
        textBox2.Visible = false;
        textBox3.Visible = false;
        label1.Visible = true;
        textBox1.Visible = true;
        button7.Visible = true;
        choice = 1;
    }

【问题讨论】:

  • 这就是你要找的textBox1.Focus()

标签: c# winforms


【解决方案1】:

你这样做:

textBox1.Focus();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多