2
我想插入一個字符串在光標位置..我正在寫一個語法高亮度控件,我想做一個函數,以便用戶可以註釋掉一行碼。 「// blah」這一切只會插入指定的註釋標識符。在RichTextBox光標位置插入字符串
我想插入一個字符串在光標位置..我正在寫一個語法高亮度控件,我想做一個函數,以便用戶可以註釋掉一行碼。 「// blah」這一切只會插入指定的註釋標識符。在RichTextBox光標位置插入字符串
richTextBox1.SelectionLength = 0;
richTextBox1.SelectedText = "//";
richTextBox.GetCharIndexFromPosition(Point point)
會給你字符索引。
另一種方法,可以幫助你:
richTextBox.GetFirstCharIndexFromLine(int lineNumber);
richTextBox.GetFirstCharIndexOfCurrentLine();
richTextBox.GetLineFromCharIndex(int index);