Why can't I change the backcolor property at design time or runtime?

I need to have a dashboard label, and its background color is changed at runtime, but no matter what I do. He simply will not change his reverse side, even if they give the opportunity to change his reverse side. Why is this and how can you return the backcolor property at run time or development time?

Thanks in advance,

+4
source share
1 answer

This is affected by the setting of ToolStrip RenderMode. Only when you change it to System will the BackColor property have an effect. Other renderers use theme colors. You probably won’t really like the system, but you can try and eat it by implementing your own renderer. Make it look like this:

public partial class Form1 : Form { public Form1() { InitializeComponent(); this.toolStrip1.Renderer = new MyRenderer(); } private class MyRenderer : ToolStripProfessionalRenderer { protected override void OnRenderLabelBackground(ToolStripItemRenderEventArgs e) { using (var brush = new SolidBrush(e.Item.BackColor)) { e.Graphics.FillRectangle(brush, new Rectangle(Point.Empty, e.Item.Size)); } } } } 
+7
source

Source: https://habr.com/ru/post/1380001/


All Articles