Ticket Q510918
Visible to All Users

Move Caret to top visible line?

created 12 years ago

How do I move the cursor (caret) to the top-most visible line on the screen, in the Rich Edit?

Thanks.

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hi,
There is no standard method to accomplish this task. However, you can try the following approach to search and calculate the required position:

C#
DocumentPosition documentPosition = null; int searchLocation1 = 0; int searchLocation2 = 0; do { searchLocation1+=2; searchLocation2++; Point clientPoint = new Point(searchLocation1, searchLocation2); Point documentPoint = Units.PixelsToDocuments(clientPoint, richEditControl1.DpiX, richEditControl1.DpiY); documentPosition = richEditControl1.GetPositionFromPoint(documentPoint); } while (documentPosition == null); richEditControl1.Document.CaretPosition = documentPosition; richEditControl1.Focus();

Attached is a complete code example. I hope this information helps you.
Thanks,
Alessandro.

    Comments (2)
    DT DT
    Dan Thomas (dagware) 12 years ago

      Thanks! Works great.

      Alessandro (DevExpress Support) 12 years ago

        You are welcome! We are always glad to help you in case of any problems.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.