• λ我爱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 &#123; /// <summary> /// ColoredRadioButton 的摘要说明。 /// </summary> public class CustomColorRadioButton : RadioButton &#123; private Color checkColor; public CustomColorRadioButton() &#123; this.checkColor = this.ForeColor; this.Paint += new PaintEventHandler(this.PaintHandler); &#125; [Description("The color used to display the check painted in the RadioButton")] public Color CheckColor &#123; get &#123; return checkColor; &#125; set &#123; checkColor = value; this.Invalidate(); &#125; &#125; private void PaintHandler (object sender, PaintEventArgs pe) &#123; if (this.Checked) &#123; Point pt = new Point(); if (this.CheckAlign == ContentAlignment.BottomCenter) &#123; pt.X = (this.Width / 2) - 3; pt.Y = this.Height - 9; &#125; if (this.CheckAlign == ContentAlignment.BottomLeft) &#123; pt.X = 4; pt.Y = this.Height - 9; &#125; if (this.CheckAlign == ContentAlignment.BottomRight) &#123; pt.X = this.Width - 9; pt.Y = this.Height - 9; &#125; if (this.CheckAlign == ContentAlignment.MiddleCenter) &#123; pt.X = (this.Width / 2) - 3; pt.Y = (this.Height / 2) - 3; &#125; if (this.CheckAlign == ContentAlignment.MiddleLeft) &#123; pt.X = 4; pt.Y = (this.Height / 2) - 3; &#125; if (this.CheckAlign == ContentAlignment.MiddleRight) &#123; pt.X = this.Width - 9; pt.Y = (this.Height / 2) - 3; &#125; if (this.CheckAlign == ContentAlignment.TopCenter) &#123; pt.X = (this.Width / 2) - 3; pt.Y = 4; &#125; if (this.CheckAlign == ContentAlignment.TopLeft) &#123; pt.X = 4; pt.Y = 4; &#125; if (this.CheckAlign == ContentAlignment.TopRight) &#123; pt.X = this.Width - 9; pt.Y = 4; &#125; DrawCheck(pe.Graphics, this.checkColor,pt); &#125; &#125; public void DrawCheck(Graphics g, Color c, Point pt) &#123; 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); &#125; &#125; &#125;

    Ҷƪл˵?
  • һƪC#中读取数据库中Image数据
    һƪC#编程入门三部曲:第一步 创建一个表单