locked
How can i set the cusrsor point (caret position) of RichEditTextbox in WinRT?

    Question

  • Already tried to set by using 
     richtextbox.Document.Selection.StartPosition = 0;

    Thursday, May 28, 2015 1:53 PM

Answers

  • It's different to wpf.

    You do it like:

    var selection = reb.Document.Selection;
    selection.StartPosition = 1;
    selection.EndPosition = 2;
    reb.Focus(FocusState.Keyboard);

    Where reb is your richeditbox.

    That's selecting one letter of course.

    For position 0:

                reb.Document.SetText(Windows.UI.Text.TextSetOptions.None, "abcdefghijklmnopqr");
                var selection = reb.Document.Selection;
                selection.StartPosition = 0;
                selection.EndPosition = 0;
                reb.Focus(FocusState.Keyboard);


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles


    Thursday, May 28, 2015 2:21 PM

All replies

  • It's different to wpf.

    You do it like:

    var selection = reb.Document.Selection;
    selection.StartPosition = 1;
    selection.EndPosition = 2;
    reb.Focus(FocusState.Keyboard);

    Where reb is your richeditbox.

    That's selecting one letter of course.

    For position 0:

                reb.Document.SetText(Windows.UI.Text.TextSetOptions.None, "abcdefghijklmnopqr");
                var selection = reb.Document.Selection;
                selection.StartPosition = 0;
                selection.EndPosition = 0;
                reb.Focus(FocusState.Keyboard);


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles


    Thursday, May 28, 2015 2:21 PM
  • Thanks a lot it's working
    Thursday, May 28, 2015 4:14 PM