c#启动时窗口默认光标聚焦位置设置 您所在的位置:网站首页 C语言图像处理怎么初始化光标 c#启动时窗口默认光标聚焦位置设置

c#启动时窗口默认光标聚焦位置设置

2024-07-09 17:01| 来源: 网络整理| 查看: 265

选中该文本框,右击属性,里的tabIndex设为0,焦点就默认在这个文本框里了。

Formload里面添加:

比如编辑框的名字:textBox_password

this.BeginInvoke((MethodInvoker)delegate {                 textBox_password.Focus();             });

private void button_Search_Click(object sender, EventArgs e) { string str1; // strDate= dateTimePicker1.ToString("yyyyMMdd"); str1 = dateTimePicker1.Value.ToString("yyyyMMdd"); str1 += ".txt"; textBox1.Text = ""; try { string[] ReadData = File.ReadAllLines(Application.StartupPath + "\\" + str1, Encoding.UTF8); // textBox1.Text = ReadData[0]; for (int i = 0; i < ReadData.Length; i++) { textBox1.Text += ReadData[i]; textBox1.Text += "\r\n"; } // textBox1.Select(0, 0);//光标停留的位置 // textBox1.Focus();//可以显示光标 // textBox1.SelectionStart = textBox1.Text.Length; textBox1.Select(textBox1.Text.Length, 0);//光标停留在最后末尾 } catch (Exception ex) { MessageBox.Show("所选日期无报警记录"); } }



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有