毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> net技术 >> 正文

重写textbox控件的enabled属性,修改enabled=false时字体颜色

更新时间:2013-3-11:  来源:毕业论文

重写textbox控件的enabled属性,修改enabled=false时字体颜色
protected override void OnPaint(PaintEventArgs args)         {             base.OnPaint(args);             if (!Enabled)             {                 args.Graphics.DrawString(Text, Font, new SolidBrush(Color.DimGray), new PointF(0.0F, 0.0F));             }         }           protected override void OnEnabledChanged(EventArgs e)         {            毕业论文  if (Enabled)             {                 this.SetStyle(ControlStyles.UserPaint, false);                 this.Font = new System.Drawing.Font(Font.FontFamily, Font.Size, Font.Style, Font.Unit);             }             else            {                 this.SetStyle(ControlStyles.UserPaint, true);             }               base.OnEnabledChanged(e);         }


绘制都是从左往右进行的,没办法从右到左绘。换个思路,在OnPaint事件中把字进行一下处理,左右调换
protected override void OnPaint(PaintEventArgs args)         {             base.OnPaint(args);             if (!Enabled)             {                 StringFormat TitleFormat = new StringFormat();                 if (this.TextAlign == HorizontalAlignment.Center)                 {                     TitleFormat.Alignment = TitleFormat.LineAlignment = StringAlignment.Center;                 }                 else if (this.TextAlign == HorizontalAlignment.Right)                 {                     TitleFormat.Alignment = TitleFormat.LineAlignment = StringAlignment.Far;                 }                 else                {                     TitleFormat.Alignment = TitleFormat.LineAlignment = StringAlignment.Near;                 }                 args.Graphics.DrawString(Text, Font, new SolidBrush(Color.Red), args.ClipRectangle, TitleFormat);             }         }

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。