Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我在列表框中选择一个项目时,一个文本框会填充所选文本以进行编辑。如何让光标专注于文本框文本,这样我就不必在编辑之前用鼠标单击它?
只需使用控件的Focus方法:
Focus
TextBox1.Text = selectedItemText; TextBox1.Focus();
或者
TextBox1.Select();
或者,如果您只想将光标放在 TextBox 中的最后一个字母之后:
TextBox1.Select(TextBox1.Text.Length, 0); TextBox1.Focus();