RichTextBox- :((
-
In window Form : I want to identify the row and colum of edit cursor .when I use movement key or mouse click ,i still know position of cursor (row and colum) .So what to do that . Sorry for my english !
Well, before even going into the details, can you tell us why do you whant to do that? May be a alternative/simpler approach can help you.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Well, before even going into the details, can you tell us why do you whant to do that? May be a alternative/simpler approach can help you.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
This might give you a little idea:
private void richTextBox1_MouseHover(object sender, EventArgs e)
{
Point _location = richTextBox1.GetPositionFromCharIndex(richTextBox1.Text.Length - 1);
MessageBox.Show(string.Format("{0}, {1}",
_location.X,
_location.Y));
}Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
This might give you a little idea:
private void richTextBox1_MouseHover(object sender, EventArgs e)
{
Point _location = richTextBox1.GetPositionFromCharIndex(richTextBox1.Text.Length - 1);
MessageBox.Show(string.Format("{0}, {1}",
_location.X,
_location.Y));
}Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
Sorry , i want to identify the row and column of editing cursor . for example : I paste a document to richtextbox end then i use "up key" or "down key" to move the edting cursor and then i know the position of editing cursor . Please help me ! Sorry for my english.
-
Sorry , i want to identify the row and column of editing cursor . for example : I paste a document to richtextbox end then i use "up key" or "down key" to move the edting cursor and then i know the position of editing cursor . Please help me ! Sorry for my english.
Something like this would work but I doubt it is the best way to do it....
private void richTextBox1\_KeyUp(object sender, KeyEventArgs e) { int totalLength = 0; int line = 0; int pos = 0; for (int i = 0; i < richTextBox1.Lines.Length; i++) { if(i != 0) totalLength++; totalLength += richTextBox1.Lines\[i\].Length; if (totalLength >= richTextBox1.SelectionStart) { line = i + 1; pos = richTextBox1.SelectionStart - (totalLength - richTextBox1.Lines\[i\].Length); break; } } label1.Text = "Line " + line.ToString() + "; Char " + pos.ToString(); }
-
In window Form : I want to identify the row and colum of edit cursor .when I use movement key or mouse click ,i still know position of cursor (row and colum) .So what to do that . Sorry for my english !
Hi, I haven't used it myself (I don't like RTB that much) but this looks like the right tool[^] for you. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.