C # WinForm Program ToolStrip ToolStripButton background is blue, how to change the background and border color and style it?
Implementing this feature requires overriding the ToolStripButton paint method
Here are just a few ideas and ways to solve the problem, for example, when you move the mouse over the button, the background turns black.
Implementation code such as the following:
ToolStripButton TSB = (ToolStripButton) sender; Rectangle Rectbutton = TSB. Bounds; Point P = toolstrip1.pointtoclient (control.mouseposition); if (Rectbutton.contains (p)) { e.graphics.clear (systemcolors.controltext); if (TSB. Image! = null) { e.graphics.drawimage (TSB. Image, New Point (E.CLIPRECTANGLE.WIDTH-TSB. Image.width)/2, (E.CLIPRECTANGLE.HEIGHT-TSB. Image.height)/2)); } }
source code Download:C#winform program ToolStripButton self-defined background Application Demo sample source code
C#winform program ToolStripButton self-defined background Application Demo sample source code