Caret positioning in richtexteditor

5 posts, 1 answers
  1. Mattiullah
    Mattiullah avatar
    5 posts
    Member since:
    Jul 2014

    Posted 11 Mar 2016 Link to this post

    i need some help in    radRichTextEditor1_Keydown

            If e.keycode= keys.right Then

    then caret goes back two letter

    and

            ElseIf   e.keycode= keys.left  Then
    then caret goes forward two letter

            End If

  2. Answer
    Hristo
    Admin
    Hristo avatar
    922 posts

    Posted 11 Mar 2016 Link to this post

    Hello Mattiullah,

    Thank you for writing.

    RadRichTextEditor exposes API for positioning within the document. Detailed information is available here: Positioning.

    The described behavior can be accomplished by handling the KeyDown event of the editor this way:
    private void radRichTextEditor1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Right)
        {
            DocumentPosition position = this.radRichTextEditor1.Document.CaretPosition;
            position.MoveToNext();
        }
        else if (e.KeyCode == Keys.Left)
        {
            DocumentPosition position = this.radRichTextEditor1.Document.CaretPosition;
            position.MoveToPrevious();
        }
    }

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. Mattiullah
    Mattiullah avatar
    5 posts
    Member since:
    Jul 2014

    Posted 11 Mar 2016 in reply to Hristo Link to this post

    it shows an error

     

    SeverityCodeDescriptionProjectFileLine
    ErrorBC30002Type 'DocumentPosition' is not defined.UrduC:\Users\PakDev.DESKTOP-E32MNMH\Documents\Visual Studio 2015\Projects\Urdu\Urdu\MainForm.vb32

  4. Mattiullah
    Mattiullah avatar
    5 posts
    Member since:
    Jul 2014

    Posted 11 Mar 2016 in reply to Mattiullah Link to this post

    thanks
  5. Hristo
    Admin
    Hristo avatar
    922 posts

    Posted 14 Mar 2016 Link to this post

    Hello Mattiullah,

    I am glad I managed to help.

    Please let me know if you need further assistance.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top