简体   繁体   English

将插入符号位置移动到特定的X,y坐标

[英]Move The Caret Position To The Particular X,y Coordinates

How to move my Carete Postion to the particular X,Y coordinates. 如何将我的Carete位置移动到特定的X,Y坐标。

Is it Possible to do it. 有可能做到这一点。

I have Two Richtextbox And I want to move the 2nd richtextbox Carete position to the 1st richtextbox Y coordinates. 我有两个Richtextbox,并且我想将第二个Richtextbox Carete位置移到第一个Richtextbox Y坐标。

You can convert the Point that was clicked on to a pointer into the text 您可以将单击的Point转换为文本指针

 var index = d.GetPositionFromPoint(point, true);
 d.CaretIndex = index;

where d is your RichTextBox. d是您的RichTextBox。

 Rect rec1= myrichtextbox1.CaretPosition.GetCharacterRect(LogicalDirection.Forward);
Rect rec2= myrichtextbox2.CaretPosition.GetCharacterRect(LogicalDirection.Forward);

myrichtextbox2.CaretPosition = myrichtextbox1.GetPositionFromPoint(new Point(rec2.X, rec1.Y), snapToText);
        CommentsEditor.CaretPosition.InsertTextInRun("your Text");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM