I need to know the exact point location in my window where the caret currently resides so that I can pop up a small window under the text (similar to intellisense or a spell
Here is my solution:
private Point GetCaretPosition()
{
Point result = TextBox.GetPositionFromCharIndex(TextBox.SelectionStart);
if (result.X == 0 && TextBox.Text.Length > 0)
{
result = TextBox.GetPositionFromCharIndex(TextBox.Text.Length - 1);
int s = result.X / TextBox.Text.Length;
result.X = (int)(result.X + (s * 1.3));
}
return result;
}