ToolStrip to have backgroundStrip gradient menu

I have a form with a menu and a toolbar at the top. The Strip menu has a nice gradient background view, how can I get the same effect from the toolStrip control? I know about the RenderMode property, but changing this does not have the desired result.

toolStrip background

+4
source share
1 answer

This can be done using a custom visualization tool.

public class CustomToolStripRenderer : ToolStripProfessionalRenderer { public CustomToolStripRenderer() { } protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) { //you may want to change this based on the toolstrip dock or layout style LinearGradientMode mode = LinearGradientMode.Horizontal; using (LinearGradientBrush b = new LinearGradientBrush(e.AffectedBounds, ColorTable.MenuStripGradientBegin, ColorTable.MenuStripGradientEnd, mode)) { e.Graphics.FillRectangle(b, e.AffectedBounds); } } } 

Then install your dashboard to use an instance of this visualizer.

 public Form1() { InitializeComponent(); CustomToolStripRenderer r = new CustomToolStripRenderer(); r.RoundedEdges = false; toolStrip1.Renderer = r; } 
+1
source

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


All Articles