none
How to set and get text from RichEditBox in WinRT/windows store apps?

    Question

  • This link shows the documentation of RichEditBox for WinRT.

    Please post some real working code samples on how to get the text from richeditbox and set the text at richeditbox. Please don't just post a random link to some documentation that doesn't have sample codes.

    Thanks

    Friday, March 22, 2013 7:40 PM

Answers

  • Here is example to set and get text from RichEditTextBox

    set

                richText.Document.SetText(Windows.UI.Text.TextSetOptions.None, "Here is text");
    

    get

     string value = string.Empty;
                richText.Document.GetText(Windows.UI.Text.TextGetOptions.AdjustCrlf, out value);


    Thanks, Sachin

    Saturday, March 23, 2013 4:37 AM

All replies

  • Have you taken a look at the QuickStart sample that shows how you can use the different type of text controls? http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh700391

    Also, http://code.msdn.microsoft.com/windowsapps/XAML-text-editing-sample-fb0493ad has a sample code and Scenario 6 goes through the RichEditBox

    Thanks,

    Prashant.


    @prashantphadke || Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog! http://aka.ms/t4vuvz

    Friday, March 22, 2013 11:54 PM
    Moderator
  • Hi, thanks for the links, those are really great.

    Unfortunately I still can't figure out how to retrieve text from RichEditBox.

    I can set the text using this code:

    questionBox.Document.Selection.Text = "Hello richbox";

    But I was trying to get texts using this code, which seems not to work.

    string msg;
                    questionBox.Document.GetText(TextGetOptions.FormatRtf,out msg);

    I am obviously missing out something important. Please help!

    Saturday, March 23, 2013 3:43 AM
  • Here is example to set and get text from RichEditTextBox

    set

                richText.Document.SetText(Windows.UI.Text.TextSetOptions.None, "Here is text");
    

    get

     string value = string.Empty;
                richText.Document.GetText(Windows.UI.Text.TextGetOptions.AdjustCrlf, out value);


    Thanks, Sachin

    Saturday, March 23, 2013 4:37 AM