This is a migrated thread and some comments may be shown as answers.

Need very simple copy/paste example

1 Answer 198 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Richard Harrigan
Top achievements
Rank 1
Richard Harrigan asked on 21 Jul 2013, 12:01 AM
Hi

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.

Thanks
Rich

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 24 Jul 2013, 04:12 PM
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()
    {
        InitializeComponent();
        this.editor.ChangeParagraphLineSpacing(1);
     
        this.editor.DocumentChanged += editor_DocumentChanged;
    }
     
    void editor_DocumentChanged(object sender, EventArgs e)
    {
        this.editor.Document.Selection.SelectAll();
        this.editor.ChangeParagraphLineSpacing(1);
    }
  • 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.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
Tags
RichTextBox
Asked by
Richard Harrigan
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or