Reputation: 604
I'm trying to insert a string at the cursor's position.. I'm writing a syntax highlighter control and I'm wanting to make a function so the user can comment out a line of code. "// blah" all this would do is insert the specified comment identifier..
Upvotes: 2
Views: 2739
Reputation: 942348
richTextBox1.SelectionLength = 0;
richTextBox1.SelectedText = "//";
Upvotes: 2
Reputation: 16162
richTextBox.GetCharIndexFromPosition(Point point)
Will give you the character index.
Another method that could help you:
richTextBox.GetFirstCharIndexFromLine(int lineNumber);
richTextBox.GetFirstCharIndexOfCurrentLine();
richTextBox.GetLineFromCharIndex(int index);
Upvotes: 0