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

Database into radRichTextBox

3 Answers 141 Views
RichTextBox (obsolete as of Q3 2014 SP1)
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 28 Oct 2011, 03:11 PM
OK, I'm quite new at these controls, and when I have my database code attempt to insert text/rtf into the Rich Textbox, I use txtBox.text=reader etc.  However, nothing happens. I know this control is different but I'm stumped. How do I load text, doc and rtf from my database into the radRichTextBox?

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 01 Nov 2011, 11:05 AM
Hi John,

Please find the answer to your questions in the Support Thread which you have opened. 

As you probably noticed, Support Treads are answered according to your support package (in your case 24 hrs, business days only), while forum threads are usually reviewed within 72 hrs (business days only) . So if you need an urgent response, please use the support channel. Alternatively, if you want to discuss or share something with the community, feel free to use our forums.

I hope that you find this information useful.
 
Regards,
Stefan
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
GM
Top achievements
Rank 1
answered on 08 Dec 2011, 11:33 PM
I am also curious about this answer - is it possible to add the answer to the forum as I cannot see the support thread being mentioned above.
0
Nikolay
Telerik team
answered on 11 Dec 2011, 07:13 PM
Hello Gm,

Please find the answer below:

As this article states, here is how to import a Word document in RadRichTextBox document:

public RadDocument ImportDocx()
{
    RadDocument document = null;
    IDocumentFormatProvider provider = new DocxFormatProvider();
    OpenFileDialog openDialog = new OpenFileDialog();
    openDialog.Filter = "Documents|*.docx";
    openDialog.Multiselect = false;
    DialogResult dialogResult = openDialog.ShowDialog();
    if (dialogResult == System.Windows.Forms.DialogResult.OK)
    {
        using (FileStream stream = new FileStream(openDialog.FileName, FileMode.Open))
        {
            document = provider.Import(stream);
        }
    }
    return document;
}

Afterwards, simply set the returned document to the control's document:
private void radButton1_Click(object sender, EventArgs e)
{
   radRichTextBox1.Document = ImportDocx();
}

That is what it takes to load a word document in RadRichTextBox. Attached you can find a sample project with a sample word file, demonstrating the described approach.

Regards,
Nikolay
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
RichTextBox (obsolete as of Q3 2014 SP1)
Asked by
John
Top achievements
Rank 1
Answers by
Stefan
Telerik team
GM
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or