C# The background of the toolStripButton in the toolStrip of the Winform program is blue. How to change the color and style of the background and border?
To implement this function, you need to override the Paint method of toolStripButton
Here are just ideas and methods to solve the problem, as shown below, when the mouse Move to the button, the background will change to black
The implementation code is as follows:
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)); } }
The above is the detailed content of Detailed explanation of the toolStripButton custom background application sample source code of the c#Winform program. For more information, please follow other related articles on the PHP Chinese website!