Need very simple copy/paste example

2 posts, 0 answers
  1. Richard Harrigan
    Richard Harrigan avatar
    235 posts
    Member since:
    Nov 2009

    Posted 20 Jul 2013 Link to this post


    I need to do something that II assume is very simple and hope there is a simple example that I could reference or even better a code snippet.

    Using Plain Text only
    No special formatting is required except to recognize carriage return and tab

    Set Line Spacing 1.0
    Set FontSize 10

    I tried changing those properties but my values were not effective

    Paste from the clipboard a simple plain text string to the RichTextBox  (This makes up the complete document)

    Read a text file into the RichTextBox This makes up the complete document)

    Get complete data string from RichTextBox to string.

    I can do this quite easily in Microsoft's RichTextBox but since the scrollbars look different than Teleriks scrollbars I can't use the microsoft RichTextBox.  .One feature of the microsoft RichTextBox that I like is when I copy the sql string from the Sql Server Data Management Studio and paste it to the RichTextBox it picks up the colors, font, fontsize etc.  I would like that but I can live without it.

  2. Petya
    Petya avatar
    983 posts

    Posted 24 Jul 2013 Link to this post

    Hi Rich,

    Thank you for contacting us!

    Straight to your questions:
    • There is a ready-to-use example on how to strip our rich text formatting capabilities in our SDK repository here. I suggest you revise it and get back to us if you have any comments or questions.
    • You can refer to this help article in order to learn how you can change the default style settings of RadRichTextBox. Additionally, as LineSpacing is a property of Paragraph, you can change it on a per-document basis by changing it for the initially loaded empty document (which actually contains a single paragraph) and for each document loaded afterwards like this:
      public MainWindow()
          this.editor.DocumentChanged += editor_DocumentChanged;
      void editor_DocumentChanged(object sender, EventArgs e)
    • Clipboard Support is provided for rich text, as well as for plain text. Please refer to this help article explaining the use of clipboard handlers and demonstrating how you can clear the default handlers and add only a handler which uses TxtFormatProvider.
    • Import/Export is fairly easy when using the format providers shipped with RadRichTextBox. In your case I'd suggest the TxtFormatProvider and if you are in need of a data-bound scenario, the respective data provider.

    Regarding code formatting, by default rich text clipboard is available so pasting code will result in the formatting being preserved. However, if you decide to clear the clipboard handlers in order to restrict pasting to plain text, this will not be possible.

    What I could probably suggest in this regard is to take advantage of the recently released Code Blocks feature. You could place a button in your application that invokes the respective dialog and syntax formatting will be available. Note that it will still be stripped when exporting with TxtFormatProvider.

    I hope the provided information is helpful! Let us know if you need further assistance.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top