C# 在RichTextBox的光标位置插入字符串
我正在尝试在光标位置插入字符串。。我正在写一个语法高亮控件,我想做一个函数,这样用户可以注释掉一行代码。“//blah”所有这些操作都将插入指定的注释标识符C# 在RichTextBox的光标位置插入字符串,c#,string,richtextbox,C#,String,Richtextbox,我正在尝试在光标位置插入字符串。。我正在写一个语法高亮控件,我想做一个函数,这样用户可以注释掉一行代码。“//blah”所有这些操作都将插入指定的注释标识符 richTextBox.GetCharIndexFromPosition(Point point) 将为您提供字符索引 另一种可以帮助您的方法: richTextBox.GetFirstCharIndexFromLine(int lineNumber); richTextBox.GetFirstCharIndexOfCurrentLine
richTextBox.GetCharIndexFromPosition(Point point)
将为您提供字符索引
另一种可以帮助您的方法:
richTextBox.GetFirstCharIndexFromLine(int lineNumber);
richTextBox.GetFirstCharIndexOfCurrentLine();
richTextBox.GetLineFromCharIndex(int index);
richTextBox1.SelectionLength = 0;
richTextBox1.SelectedText = "//";