In demo project if I set radRichTextEditor1.RichTextBoxElement.BackColor = Color.Aqua in constructor I see the background color changed in web layout. But in print layout only the color of the background behind the pages is changed. How to change the color of the pages too?
3 Answers, 1 is accepted
0
Accepted
Hi Mihajlo,
The page elements are created dynamically and they cannot be accessed in the code. What you need to do is edit the theme in code and set the BackColor. Here is the code:
This will work with themes that have BackColor set to other than white (White is the default color and there are no explicit settings for it). With the themes where the color is white, you can edit the theme in Visual Style Builder and set the color, but this is a complex because you need to export and edit the predefined theme and then load it in your project. If you let me know what theme you want to use I will prepare an example that shows this as well.
I am looking forward to your reply.
Regards,
Dimitar
Progress Telerik
The page elements are created dynamically and they cannot be accessed in the code. What you need to do is edit the theme in code and set the BackColor. Here is the code:
public
void
SetBackColor()
{
this
.radRichTextEditor1.RichTextBoxElement.BackColor = Color.Red;
Theme theme = ThemeRepository.FindTheme(
"TelerikMetro"
);
foreach
(var styleGroup
in
theme.StyleGroups)
{
foreach
(PropertySettingGroup settingGroup
in
styleGroup.PropertySettingGroups)
{
if
(settingGroup.Selector.Value ==
"Telerik.WinControls.RichTextEditor.UI.Page"
)
{
foreach
(PropertySetting property
in
settingGroup.PropertySettings)
{
if
(property.Name ==
"BackColor"
)
{
property.Value = System.Drawing.Color.Red;
}
}
}
if
(settingGroup.Selector.Value ==
"Telerik.WinControls.RichTextEditor.UI.HeaderFooterContainer"
)
{
foreach
(PropertySetting property
in
settingGroup.PropertySettings)
{
if
(property.Name ==
"OverlayColor"
)
{
property.Value = System.Drawing.Color.Red;
}
}
}
}
}
}
This will work with themes that have BackColor set to other than white (White is the default color and there are no explicit settings for it). With the themes where the color is white, you can edit the theme in Visual Style Builder and set the color, but this is a complex because you need to export and edit the predefined theme and then load it in your project. If you let me know what theme you want to use I will prepare an example that shows this as well.
I am looking forward to your reply.
Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Mihajlo
Top achievements
Rank 1
answered on 22 Aug 2018, 12:45 PM
Thanks for the reply. It's true, I actually want white background. For now I'll go with ControlDefault theme. If I ever need theme functionality, I'll bear this code in mind.
Maybe these background colors for dynamic controls should take values from parent controls, where appropriate? Or introduce some new property, PageBackgroundColor, in this special case?
0
Hi Mihajlo,
Indeed there should be an easier way to change the BackColor. This is why I have logged a feature request for this in our Feedback Portal. You can track its progress, subscribe to status changes and add your comment to it here. I have also updated your Telerik Points.
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
Indeed there should be an easier way to change the BackColor. This is why I have logged a feature request for this in our Feedback Portal. You can track its progress, subscribe to status changes and add your comment to it here. I have also updated your Telerik Points.
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.