C# Winform 去掉按钮按下时周围黑线框

C# Winform 去掉按钮按下时周围黑线框
2011年03月01日
  C# Winform界面编程时拖放的按钮很不美观,如果要贴一个透明的png图片,需要做一些属性设置,this代表此Button。
  this.BackColor = System.Drawing.Color.Transparent;
  //this.BackgroundImage = global::WindowsFormsApplication1.Properties.Resour ces.back;
  this.BackgroundImage = System.Drawing.Image.FromFile("../../image/spalish .jpg");
  this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
  this.FlatAppearance.BorderSize = 0;
  this.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
  this.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
  this.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  这样设置后,按钮按下去时,还是去出现黑线框,这个黑线框通过属性设置时无法去掉的,需要自定义按钮,然后重绘。
  这个黑线框式聚焦框,有系统绘制。可以按如下方式自定义按钮后就可顺利去掉此黑线框。
  //自定义了一个Button。点击Button时不会出现黑色边框
  public class MyButton : Button
  {
  public MyButton()
  {
  }
  protected override bool ShowFocusCues
  {
  get
  {
  return false;
  }
  }
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值