winform中按钮透明的方法
2021-03-29 20:28
标签:col rgs 使用 hover image rbac winform 分享 object 把Button设为透明的方法: 2. /// private void btn_MouseLeave(object sender, EventArgs e) lable可以直接使用label1.BackColor = Color.Transparent;使其透明 winform中按钮透明的方法 标签:col rgs 使用 hover image rbac winform 分享 object 原文地址:https://www.cnblogs.com/Qing-Bo/p/9289731.html
1.修改 FlatAppearance属性下的BorderSize 为0
修改 FlatStyle 的属性为 Flat
/// 设置透明按钮样式
///
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;
}
{
Button btn = sender as Button;
btn.FlatAppearance.BorderSize = 0;
}