caret coordinates in a richtextbox (X,Y !)

i would like to create a code-snippet like dropdown menu which would load when a preset key is pressed...just like all the editors do.
For this i need the X Y coordinates of the caret in a richtextbox...
NOTE:
i do not need the line number and position of the caret but it's X Y coordinates.
any help would be apreciated.
[339 byte] By [Looooooka] at [2007-12-16]
# 1
You can try the following code:



Dim temp As Point = Me.RichTextBox1.GetPositionFromCharIndex(Me.RichTextBox1.SelectionStart)

You may need to do some additional math as this gives a coordinate relative to the top left of the RichTextBox. It also does not seem to take into account the font size but it gives a good place to start.

Hope this helps.
Kris Langohr
Visual Basic QA

KrisLa_MS at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...