In object like richtextbox takeing cursor position as X,Y cor

NAX SIS 1 Reputation point
2022-06-16T08:08:17.307+00:00

Try to implement some object in richtextbox selected text centered top of the selected line(s);

Let me demostrate with an example.

" The dog was come and go "

this is the sample sentence. with mouse or with keyboard the users select the " dog was come " and the cursor is positioned after the letter of " e| ".

what i try to get , the blinking cursor position but based on the object ( in this case the object is richtextbox ) , but getting the position of the cursor as X,Y Cordinates instead of getting a index.

(0,0)
------y|
--------| >|<
--------|
--------|--------x
--------|
--------|
--------|

this cordinates of the richtext box showed at above also the cursor is >|< mark like this , how can i get the X,Y cordinates from Richtextbox.

Thanks.

Developer technologies C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 90,521 Reputation points
    2022-06-16T08:14:37.16+00:00

    You can do something like :

     Point pt = richTextBox1.GetPositionFromCharIndex(richTextBox1.SelectionStart);  
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.