ITeye博客

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

kbk730oe · 2012-01-20 11:12 · 技术杂绘 · 非技术 · Markdown

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;   }   }
  }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。