更新时间:2023-12-06 16:32:52
根据我的理解,你想将光标的位置设置在
a TextBox中,就在第一个字符之前文本。
Based on my understanding, you'd like to set the position of the cursor in
a TextBox to just before the first character of the text.
以下是示例代码。它要求你在
表格上添加一个TextBox。
The following is a sample code. It requires that you add a TextBox on a
form.
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.Text = "hell world text testing cursor pointer ...";
this.textBox1.SelectionStart = 0;
}
或
检查
具有搜索行编号,项目符号,打印,搜索支持的RichTextBox [ ^ ]
问候,
Praveen Nelge
or
Check it
RichTextBox with Search Line Numbering, Bulleting, Printing, Searching Support[^]
Regards,
Praveen Nelge
int position = 0;
public void GotoLine(int LineNum) // Go to line num...
{
position = 0;
for (int i = 1; i <= LineNum; i++)
FindNext("\n");
}
public void FindNext(string FindValue) // Find word...
{
int start = this.TextBox1.Text.IndexOf(FindValue, position);
int length = FindValue.Length;
this.TextBox1.Select(start, length);
position = start + length;
}
-KR
-KR