Control renderer Demo: CheckBox : Control « GUI Windows Form « C# / C Sharp






Control renderer Demo: CheckBox

Control renderer Demo: CheckBox
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

public class Form1 : Form
{

      public Form1() {
            InitializeComponent();
            
      }

    private void ControlRenderer_Paint(object sender, PaintEventArgs e)
    {
      
        CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(10,10),
          new Rectangle(10,10,110,15), "Style checkbox", Font,false, CheckBoxState.CheckedNormal);
      
    }
    private void InitializeComponent()
    {
      this.SuspendLayout();
      // 
      // ControlRenderer
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(292, 266);
      this.Name = "ControlRenderer";
      this.Text = "ControlRenderer";
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.ControlRenderer_Paint);
      this.ResumeLayout(false);

    }
      [STAThread]
      static void Main()
      {
        Application.EnableVisualStyles();
        Application.Run(new Form1());
      }

}



           
       








Related examples in the same category

1.Use Control.GetType to check the control type
2.Control Enabled
3.Add a Control ProgrammaticallyAdd a Control Programmatically
4.Change Image alignment inside a ControlChange Image alignment inside a Control
5.Get all controls on a form windowGet all controls on a form window
6.Control style: resize and redrawControl style: resize and redraw