One movement with ControlPaint
Description :
We can draw our own size of controls.
For Example we cannot increase the size of the checkbox.
But by using the bellow code we can create the big size of checkbox.
Used Namespaces
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
Code Part
public class ControlPaintForm : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public ControlPaintForm()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "ControlPaint";
this.Text = "ControlPaint";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.ControlPaint_Paint);
}
private void ControlPaint_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(11, 11, 55, 55), ButtonState.Checked);
ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(70, 10, 30, 30), ButtonState.Normal);
ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(110, 11, 25, 25), ButtonState.Checked);
ControlPaint.DrawButton(e.Graphics, new Rectangle(10, 80, 18, 18), ButtonState.Checked);
ControlPaint.DrawButton(e.Graphics, new Rectangle(50, 80, 18, 18), ButtonState.Flat);
ControlPaint.DrawButton(e.Graphics, new Rectangle(90, 80, 18, 18), ButtonState.Normal);
ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(130, 80, 18, 18));
ControlPaint.DrawGrid(e.Graphics, new Rectangle(10, 120, 250, 50), new Size(5, 5), Color.Blue);
ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(10, 180, 21, 21), ScrollButton.Left, ButtonState.Normal);
ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(50, 180, 21, 21), ScrollButton.Max, ButtonState.Pushed);
ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(90, 180, 21, 21), ScrollButton.Up, ButtonState.Normal);
ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle(10, 220, 21, 21), MenuGlyph.Arrow);
ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle(50, 220, 21, 21), MenuGlyph.Checkmark);
ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle(90, 220, 21, 21), MenuGlyph.Max);
}
[STAThread]
static void Main()
{
Application.Run(new ControlPaintForm());
}
}
Code Explanation
1. The above code is like a mapaint
2. Override "Dispose" for clean up any resources being used.
3. ControlPaint is used to create our own size controls.
By
Nathan