c#Winform程序的toolStripButton自定义背景应用示例源码
2020-12-13 04:39
标签:c# winform toolstrip 自定义背景 C# Winform程序的toolStrip中toolStripButton的背景是蓝色的,如何改变背景及边框的颜色和样式呢? 实现此功能需要重写toolStripButton的Paint方法 这里只是给出解决问题的思路和方法,如下图,当鼠标移到按钮上,背景会变为黑色 实现代码如下: c#Winform程序的toolStripButton自定义背景应用示例源码,搜素材,soscw.com c#Winform程序的toolStripButton自定义背景应用示例源码 标签:c# winform toolstrip 自定义背景 原文地址:http://blog.csdn.net/testcs_dn/article/details/37760439 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));
}
}
源码下载:c#Winform程序的toolStripButton自定义背景应用示例源码
文章标题:c#Winform程序的toolStripButton自定义背景应用示例源码
文章链接:http://soscw.com/index.php/essay/29718.html