我爱Aspx >> C#.Net >> 为你的CheckBox和RadioButton控件添色加彩
为你的CheckBox和RadioButton控件添色加彩
- :aspxer Դ:internet :2007-5-12 7:45:06 ؼ:
- ColoredRadioButton.cs
using System; using System.Windows.Forms; using System.Drawing; using System.ComponentModel; namespace ColorCheckControl { /// /// ColoredRadioButton 的摘要说明。 /// public class CustomColorRadioButton : RadioButton { private Color checkColor; public CustomColorRadioButton() { this.checkColor = this.ForeColor; this.Paint += new PaintEventHandler(this.PaintHandler); } [Description("The color used to display the check painted in the RadioButton")] public Color CheckColor { get { return checkColor; } set { checkColor = value; this.Invalidate(); } } private void PaintHandler (object sender, PaintEventArgs pe) { if (this.Checked) { Point pt = new Point(); if (this.CheckAlign == ContentAlignment.BottomCenter) { pt.X = (this.Width / 2) - 3; pt.Y = this.Height - 9; } if (this.CheckAlign == ContentAlignment.BottomLeft) { pt.X = 4; pt.Y = this.Height - 9; } if (this.CheckAlign == ContentAlignment.BottomRight) { pt.X = this.Width - 9; pt.Y = this.Height - 9; } if (this.CheckAlign == ContentAlignment.MiddleCenter) { pt.X = (this.Width / 2) - 3; pt.Y = (this.Height / 2) - 3; } if (this.CheckAlign == ContentAlignment.MiddleLeft) { pt.X = 4; pt.Y = (this.Height / 2) - 3; } if (this.CheckAlign == ContentAlignment.MiddleRight) { pt.X = this.Width - 9; pt.Y = (this.Height / 2) - 3; } if (this.CheckAlign == ContentAlignment.TopCenter) { pt.X = (this.Width / 2) - 3; pt.Y = 4; } if (this.CheckAlign == ContentAlignment.TopLeft) { pt.X = 4; pt.Y = 4; } if (this.CheckAlign == ContentAlignment.TopRight) { pt.X = this.Width - 9; pt.Y = 4; } DrawCheck(pe.Graphics, this.checkColor,pt); } } public void DrawCheck(Graphics g, Color c, Point pt) { Pen pen = new Pen(this.checkColor); g.DrawLine(pen, pt.X, pt.Y + 1, pt.X + 3, pt.Y + 1); g.DrawLine(pen, pt.X, pt.Y + 2, pt.X + 3, pt.Y + 2); g.DrawLine(pen, pt.X + 1, pt.Y, pt.X + 1, pt.Y + 3); g.DrawLine(pen, pt.X + 2, pt.Y, pt.X + 2, pt.Y + 3); } } }
Ҷƪл˵?
- һƪC#中读取数据库中Image数据
һƪC#编程入门三部曲:第一步 创建一个表单
- 关于我们 | 广告服务 | 网站建设 | 版权申明 | 申请链接 | 联系我们
- Copyright © 2007 5iaspx.COM. All Right Reserved.
- 本站内容仅供学习,研究,探讨,个人收藏,如有侵权,敬请联系我们,我们尽快解决!