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

How to set a black background and white text

6 Answers 574 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Bart
Top achievements
Rank 1
Bart asked on 25 Apr 2016, 01:56 PM

Hi,

I'm trying to get the richtexteditor to display white text on a black background. (That's a requirement for us).

Simply setting the back and forecolors doesn't really work well;

_viewer.BackColor = Color.Black;
_viewer.ForeColor = Color.White;
_viewer.RichTextBoxElement.BackColor = Color.Black;
_viewer.RichTextBoxElement.ForeColor = Color.White;

I have also tried to change the paragraphs, but that still leaves a white paper, with paragraphs with  black background.

_viewer.ChangeParagraphBackground(Color.Black);
var documentEditor = new RadDocumentEditor(_viewer.Document);
documentEditor.ChangeForeColor(Color.White);
documentEditor.ChangeParagraphBackground(Color.Black);
_viewer.Document.Selection.Clear();

 

Any advice on how I can set it up ?

 

 

6 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 27 Apr 2016, 02:04 PM
Hi Bart,

Thank you for writing.

Could you please try setting the BackColor property along with calling the ChangeTextForeColor method of the editor:
this.radRichTextEditor1.RichTextBoxElement.BackColor = Color.Black;
this.radRichTextEditor1.ChangeTextForeColor(Color.White);

I am also sending you a screenshot showing the result on my end.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Bart
Top achievements
Rank 1
answered on 28 Apr 2016, 06:35 AM

Hi Hristo,

I tried this, but to no avail.

The result can be seen in the Telerik.png file (what we need is in other.png).

var rtfProvider = new RtfFormatProvider();
viewer.Document = rtfProvider.Import(CleanupRtf(value));
viewer.RichTextBoxElement.BackColor = Color.Black;
viewer.ChangeTextForeColor(Color.White);

0
Accepted
Hristo
Telerik team
answered on 28 Apr 2016, 02:52 PM
Hello Bart,

Thank you for writing.

RadRichTextEditor is a complex control and if you import a document to it this changes the layout hierarchy. The styles need to be applied to the control as well as the page. 

This can be achieved by modifying the theme you are using. I am sending you attached a screenshot showing the settings which need to be modified as well as a sample project using a single XML component for RadRichTextEditor. You can also check the following documentation resources: Themes, Visual Style Builder, RadThemeManager.

I hope this helps. Please let me know if you need further assistance.

Regards,
Hristo Merdjanov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Bart
Top achievements
Rank 1
answered on 29 Apr 2016, 09:55 AM

Hi Hristo,

thanks for this. It is much better.

I've corrected it to:

private void Viewer_DocumentChanged(object sender, EventArgs e)
{
    viewer.RichTextBoxElement.Document.Selection.SelectAll();
    viewer.RichTextBoxElement.ChangeTextForeColor(Color.White);
    viewer.RichTextBoxElement.Document.Selection.Clear();
 }

It still doens't select the headers/footers for the colors.

0
Accepted
Hristo
Telerik team
answered on 29 Apr 2016, 11:38 AM
Hi Bart,

Thank you for writing back.

If I understand correctly you are having an issue with the text color of the headers and footers after you import the RTF document.

In order to change their fore color, you would need to do something similar to changing the color of the text of the main document. Please check my code snippet below: 
private void radRichTextEditor1_DocumentChanged(object sender, EventArgs e)
{
    this.radRichTextEditor1.RichTextBoxElement.Document.Selection.SelectAll();
    this.radRichTextEditor1.RichTextBoxElement.ChangeTextForeColor(Color.White);
    this.radRichTextEditor1.RichTextBoxElement.Document.Selection.Clear();
 
    RadDocumentEditor headerEditor = new RadDocumentEditor(this.radRichTextEditor1.Document.Sections.First.Headers.Default.Body);
    this.radRichTextEditor1.Document.Sections.First.Headers.Default.Body.Selection.SelectAll();
    headerEditor.ChangeForeColor(Color.White);
 
    RadDocumentEditor footerEditor = new RadDocumentEditor(this.radRichTextEditor1.Document.Sections.First.Footers.Default.Body);
    this.radRichTextEditor1.Document.Sections.First.Footers.Default.Body.Selection.SelectAll();
    footerEditor.ChangeForeColor(Color.White);
}

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Bart
Top achievements
Rank 1
answered on 29 Apr 2016, 12:00 PM

Hi Hristo,

This works. thanksa  lot.

Tags
RichTextEditor
Asked by
Bart
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Bart
Top achievements
Rank 1
Share this question
or