怎样改变C#中button的样式
的有关信息介绍如下:完全透明的按钮,只在鼠标经过时显示边框线。
属性Button.Image设置图片按钮,可与背景完美结合。
[csharp]
view
plaincopyprint?
///
///
设置透明按钮样式
///
private
void
SetBtnStyle(Button
btn)
{
btn.FlatStyle
=
FlatStyle.Flat;//样式
btn.ForeColor
=
Color.Transparent;//前景
btn.BackColor
=
Color.Transparent;//去背景
btn.FlatAppearance.BorderSize
=
0;//去边线
btn.FlatAppearance.MouseOverBackColor
=
Color.Transparent;//鼠标经过
btn.FlatAppearance.MouseDownBackColor
=
Color.Transparent;//鼠标按下
}
private
void
btn_MouseHover(object
sender,
EventArgs
e)
{
Button
btn
=
sender
as
Button;
btn.FlatAppearance.BorderSize
=
1;
}
private
void
btn_MouseLeave(object
sender,
EventArgs
e)
{
Button
btn
=
sender
as
Button;
btn.FlatAppearance.BorderSize
=
0;
}