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#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

1 answer

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

    You can do something like :

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

    Was this answer helpful?


Your answer

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