C# 在文本框中获取焦点位置/索引
C# Get Focused Position / Index In Textbox
如何获得焦点光标索引来抑制左键
示例:
if (e.KeyCode == Keys.Left && textBox1.Text.FocusIndex == textBox1.text.IndexOf(">")+1)
{
e.SuppressKeyPress = true;
}
如果焦点光标到达“>”的下一个字符禁用向左箭头...
如何获得焦点索引或位置?
谢谢,
如果 "Focused Cursor Index" 您指的是插入符位置,您可以使用文本框的 属性 SelectionStart
。
喜欢:
if (e.KeyCode == Keys.Left == textBox1.SelectionStart == textBox1.Text.IndexOf(">"))
{
e.SuppressKeyPress = true;
}
如何获得焦点光标索引来抑制左键 示例:
if (e.KeyCode == Keys.Left && textBox1.Text.FocusIndex == textBox1.text.IndexOf(">")+1)
{
e.SuppressKeyPress = true;
}
如果焦点光标到达“>”的下一个字符禁用向左箭头... 如何获得焦点索引或位置? 谢谢,
如果 "Focused Cursor Index" 您指的是插入符位置,您可以使用文本框的 属性 SelectionStart
。
喜欢:
if (e.KeyCode == Keys.Left == textBox1.SelectionStart == textBox1.Text.IndexOf(">"))
{
e.SuppressKeyPress = true;
}