TextBox 类 netCF 中的 Click 和 Focus() 有什么区别
本文关键字:什么 区别 Focus netCF 中的 Click TextBox | 更新日期: 2023-09-27 18:33:05
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
textBox2.Focus();
}
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
CursorTest();
}
private void button4_Click(object sender, EventArgs e)
{
CursorTest();
}
private void CursorTest()
{
Cursor.Current = Cursors.WaitCursor;
for (int i = 0; i < 100; i++)
System.Diagnostics.Debug.WriteLine(i.ToString());
Cursor.Current = Cursors.Default;
}
案例 1 : 我点击按钮 4, - 光标测试() 显示等待光标
情况2:我在文本框1上输入"ENTER"并将焦点移动到文本框2
并在 textBox2 上再次输入 'ENTER' - CursorText() 不会出现等待光标。
情况 3 : 我只需单击 textBox2 并输入"ENTER" - CursorText() 出现等待光标。
如何在所有情况下显示等待光标?Click 和 Focus() 有什么区别?
检查 TextBox.TextChanged 事件并从那里调用CursorTest()
。那会起作用。
private void textBox1_TextChanged(object sender, EventArgs e)
{
CursorTest();
}