完全透明的按钮,只在鼠标经过时显示边框线。
属性Button.Image设置图片按钮,可与背景完美结合。
url:http://greatverve.cnblogs.com/archive/2012/03/13/Transparent-button.html
属性Button.Image设置图片按钮,可与背景完美结合。
/// <summary>
/// 设置透明按钮样式
/// </summary>
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;
}
/// 设置透明按钮样式
/// </summary>
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;
}
转载于:https://www.cnblogs.com/greatverve/archive/2012/03/13/Transparent-button.html