winform中的图标按钮布局 [英] Icon button layout in winform
本文介绍了winform中的图标按钮布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Windows 8,VS 2012.我在按钮上添加了一个圆形图标:
I'm working on Windows 8, VS 2012. I added a round icon to my button:
this.btn.Image = Properties.Resources.icon;
this.btn.Size = Properties.Resources.icon.Size;
我的表单也有背景图片:
Also my form has background image:
this.BackgroundImage = Properties.Resources.sunset;
但是我的图标很丑,我的图标按钮是方形的:中间的圆形图像和角落里的灰色.
But I'm getting ugly form, where my icon button is square: the round image in the middle and gray color in the corners.
问题是如何显示表单背景而不是灰色?
The question is how can I display form background instead of gray color?
感谢您的关注
推荐答案
您可以设置按钮的某些属性以获得所需的内容:
You can set some property of your button to gain what you need:
- 将按钮的
FlatStyle
属性更改为Flat
- 将其
BackColor
属性设置为Transparent
- 在
FlatAppearance
中设置BorderSize
为0. - 在
FlatAppearance
中,您还可以将MouseDownBackColor
和MouseOverBackColor
设置为表单的背景颜色或您想要的颜色.
- Change
FlatStyle
property of your button toFlat
- Set its
BackColor
property toTransparent
- In
FlatAppearance
SetBorderSize
to 0. - In
FlatAppearance
You can also setMouseDownBackColor
andMouseOverBackColor
to back color of form or the color you want.
这篇关于winform中的图标按钮布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文