Chinaunix首页 | 论坛 | 博客
  • 博客访问: 226628
  • 博文数量: 59
  • 博客积分: 3000
  • 博客等级: 中校
  • 技术积分: 1340
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-14 09:50
文章分类

全部博文(59)

文章存档

2009年(2)

2008年(57)

我的朋友
最近访客

分类:

2008-10-21 10:53:45

  //重写OnEnabledChanged  
  protected   override   void   OnEnabledChanged(EventArgs   e)  
  {  
  if     (Enabled==false){  
  SetStyle(ControlStyles.UserPaint,true);  
  }  
  else{  
  SetStyle(ControlStyles.UserPaint,false);  
  }  
  base.OnEnabledChanged(e);  
  }  
  //重写OnPaint  
  protected   override   void   OnPaint(PaintEventArgs   pe)  
  {  
  base.OnPaint(pe);  
  if   (Enabled==false){  
  pe.Graphics.FillRectangle(new   SolidBrush(SystemColors.ControlLight),  
  pe.ClipRectangle);  
  //文字描画  
  int   x=0,y=0;  
  Size   s   =   pe.Graphics.MeasureString(Text,Font).ToSize();  
  x=Width-s.Width;  
  y=(Height-s.Height)/2;  
   
  pe.Graphics.DrawString(this.Text,   this.Font,   Brushes.Black   ,   x,   y);  
  }  
   
  }
阅读(1397) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~