Caret positioning in richtexteditor

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

    Posted 11 Mar 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 Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 11 Mar 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. UI for WinForms is Visual Studio 2017 Ready
  4. Mattiullah
    Mattiullah avatar
    5 posts
    Member since:
    Jul 2014

    Posted 11 Mar in reply to Hristo Merdjanov 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

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

    Posted 11 Mar in reply to Mattiullah Link to this post

    thanks
  6. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 14 Mar 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
UI for WinForms is Visual Studio 2017 Ready