Hello guys,
In my current project, I'm making a control similar to RichTextBox. I use TextRenderer to draw text. My problem is that I can't get real column index from caret position.
Here is my code:
It returns something like half of the string :) Anyone has a solution?Code://row index -works great var y = e.Y / LineHeight; if (y >= lines.Count) y = lines.Count - 1; if (y < 0) y = 0; columnCount = y; //column index int x = 0; int i = 0; for (i = 0; (i < lines[columnCount].Length) && (x < e.X); i++) x += TextRenderer.MeasureText(lines[columnCount].Substring(0, i), Font).Width; if (i > lines[columnCount].Length) i = lines[columnCount].Length; rowIndex = i;
iRoN


Reply With Quote