c# - toolStrip to have menuStrip gradient background -
i have form menu , toolstrip @ top. menustrip has nice looking gradient background, how can same effect on toolstrip control? know rendermode property changing doesn't have desired result.
you can achieve custom renderer.
public class customtoolstriprenderer : toolstripprofessionalrenderer { public customtoolstriprenderer() { } protected override void onrendertoolstripbackground(toolstriprendereventargs e) { //you may want change based on toolstrip's 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 set toolstrip use instance of renderer.
public form1() { initializecomponent(); customtoolstriprenderer r = new customtoolstriprenderer(); r.roundededges = false; toolstrip1.renderer = r; }
Comments
Post a Comment