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

Add text from SqlDataReader

11 Answers 228 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Stas
Top achievements
Rank 1
Stas asked on 23 Feb 2015, 07:53 AM
Hello! I try to add text to RadRichTextBox but anything it is impossible!
On standard richtextbox everything is good. How here to make analog of code for RadRichTextBox? Thanks!
using (SqlDataReader dr = cmd.ExecuteReader())
              {
                  while (dr.Read())
                  richTextBox1.AppendText("\n" + dr["data"] + ": " + dr["UserName"] + ": " + dr["message"].ToString());
              }

11 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 23 Feb 2015, 09:27 AM
Hello Stas,

Thank you for writing.

Please refer to the following article which explains how you can import data in RadRichTextEditor: Import/Export | UI for WinForms Documentation.

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Stas
Top achievements
Rank 1
answered on 23 Feb 2015, 09:36 AM
No, I don't want import or export. I want to learn as to add the text in RadRichTextBox? How to add the text as on a screenshot in the attachment?
I already tried, it is impossible to me... In standard RichTextBox everything ok
0
Stas
Top achievements
Rank 1
answered on 23 Feb 2015, 12:45 PM
Forgive, my question about RadRichTextBox but not radRichTextEditor.
Please, give a code sample on my question
0
Stefan
Telerik team
answered on 25 Feb 2015, 08:09 AM
Hi,

Adding text in RadRichTextBox and RadRichTextEditor is done via importing, not with the Text property. Here is how your code will look like:
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
 
    string text = "";
 
    using (SqlDataReader dr = cmd.ExecuteReader())
    {
        while (dr.Read())
            text += "\n" + dr["data"] + ": " + dr["UserName"] + ": " + dr["message"].ToString();
    }
 
    radRichTextEditor1.Document = ImportString(text);
}
 
public RadDocument ImportXaml(string content)
{
    TxtFormatProvider provider = new TxtFormatProvider();
    return provider.Import(content);
}

Still, we do have a feature request for adding plain text or html text with the Text property. You can track its status and add your vote (like) for it here: http://feedback.telerik.com/Project/154/Feedback/Details/111956-add-radrichtextbox-init-the-content-using-text-property-with-support-of-html-f.

As to using RadRichTextBox instead of RadRichTextEditor, I would strongly recommend using the latter, as it it a much better version of the editor control.

I hope that you find this information useful.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Stas
Top achievements
Rank 1
answered on 05 Mar 2015, 07:32 PM
Thanks Bro! I love you!
0
Stas
Top achievements
Rank 1
answered on 05 Mar 2015, 07:53 PM
How to add text to an already existing? Analogue of appendtext? That would not load constantly new document...
0
Stas
Top achievements
Rank 1
answered on 05 Mar 2015, 08:39 PM
I'm sorry, did using .insert! Thanks!
0
Stas
Top achievements
Rank 1
answered on 05 Mar 2015, 08:55 PM
Oh, no! It does not work ...
radRichTextBox1.Document.Insert("dfdf", new StyleDefinition());

Text added without style html....look in attach .
And I need to be added text to html...
0
Stefan
Telerik team
answered on 06 Mar 2015, 03:24 PM
Hello Stas,

Here you are:
this.radRichTextEditor1.Document.CaretPosition.MoveToLastPositionInDocument();
this.radRichTextEditor1.Insert("alabala");

I hope this helps.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Stas
Top achievements
Rank 1
answered on 06 Mar 2015, 09:00 PM
Thanks bro, but you code inserts text without ntml, see screenshot
0
Stefan
Telerik team
answered on 10 Mar 2015, 12:58 PM
Hello Stas,

I am working with the latest version of RadRichTextEditor and the behavior is not as you described on my end. 

Importing file:
<!DOCTYPE html>
<html>
<body>
 
<span style="color:red"><strong>Здравствуйте!</strong></span>
 
</body>
</html>

results in:
…......
<body><p class="NormalWeb "><span class="s_A9BC7DFB">Здравствуйте!TEST</span></p></body></html>

Attached you can find the sample I am testing with. Can you please have a look at it and let me know how it differs from your setup?

I am looking forward to your reply.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
RichTextEditor
Asked by
Stas
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Stas
Top achievements
Rank 1
Share this question
or