<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FGUI_Windows_Forms%2FButton</id>
		<title>Csharp/CSharp Tutorial/GUI Windows Forms/Button - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FGUI_Windows_Forms%2FButton"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/GUI_Windows_Forms/Button&amp;action=history"/>
		<updated>2026-04-29T21:41:18Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/GUI_Windows_Forms/Button&amp;diff=5403&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/GUI_Windows_Forms/Button&amp;diff=5403&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/GUI_Windows_Forms/Button&amp;diff=5404&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/GUI_Windows_Forms/Button&amp;diff=5404&amp;oldid=prev"/>
				<updated>2010-05-26T12:15:20Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Add a Button==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Windows.Forms; &lt;br /&gt;
using System.Drawing; &lt;br /&gt;
 &lt;br /&gt;
class ButtonForm : Form { &lt;br /&gt;
  Button MyButton = new Button(); &lt;br /&gt;
 &lt;br /&gt;
  public ButtonForm() { &lt;br /&gt;
    Text = &amp;quot;Using a Button&amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
    MyButton = new Button(); &lt;br /&gt;
    MyButton.Text = &amp;quot;Press Here&amp;quot;; &lt;br /&gt;
    MyButton.Location = new Point(100, 200); &lt;br /&gt;
 &lt;br /&gt;
    Controls.Add(MyButton); &lt;br /&gt;
  }   &lt;br /&gt;
 &lt;br /&gt;
  [STAThread] &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ButtonForm skel = new ButtonForm(); &lt;br /&gt;
 &lt;br /&gt;
    Application.Run(skel); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Add action handler to button==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
public class ButtonActionForm : System.Windows.Forms.Form&lt;br /&gt;
{&lt;br /&gt;
  private System.Windows.Forms.Button button1;&lt;br /&gt;
  private System.ruponentModel.Container components = null;&lt;br /&gt;
  public ButtonActionForm()&lt;br /&gt;
  {&lt;br /&gt;
    InitializeComponent();&lt;br /&gt;
  }&lt;br /&gt;
  protected override void Dispose( bool disposing )&lt;br /&gt;
  {&lt;br /&gt;
    if( disposing )&lt;br /&gt;
    {&lt;br /&gt;
      if (components != null) &lt;br /&gt;
      {&lt;br /&gt;
        components.Dispose();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    base.Dispose( disposing );&lt;br /&gt;
  }&lt;br /&gt;
  private void InitializeComponent()&lt;br /&gt;
  {&lt;br /&gt;
    this.button1 = new System.Windows.Forms.Button();&lt;br /&gt;
    this.SuspendLayout();&lt;br /&gt;
    this.button1.Location = new System.Drawing.Point(109, 122);&lt;br /&gt;
    this.button1.Name = &amp;quot;button1&amp;quot;;&lt;br /&gt;
    this.button1.TabIndex = 0;&lt;br /&gt;
    this.button1.Text = &amp;quot;Say Hello&amp;quot;;&lt;br /&gt;
    this.button1.Click += new System.EventHandler(this.button1_Click);&lt;br /&gt;
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
    this.ClientSize = new System.Drawing.Size(292, 266);&lt;br /&gt;
    this.Controls.AddRange(new System.Windows.Forms.Control[] {&lt;br /&gt;
                                    this.button1});&lt;br /&gt;
    this.Name = &amp;quot;ButtonActionForm&amp;quot;;&lt;br /&gt;
    this.ResumeLayout(false);&lt;br /&gt;
  }&lt;br /&gt;
  [STAThread]&lt;br /&gt;
  static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Application.Run(new ButtonActionForm());&lt;br /&gt;
  }&lt;br /&gt;
  private void button1_Click(object sender, System.EventArgs e)&lt;br /&gt;
  {&lt;br /&gt;
    MessageBox.Show( this, &amp;quot;Hello&amp;quot; );&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Auto Scale Button==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
class MyClass: Form&lt;br /&gt;
{&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Application.EnableVisualStyles();&lt;br /&gt;
        Application.Run(new MyClass());&lt;br /&gt;
    }&lt;br /&gt;
    public MyClass()&lt;br /&gt;
    {&lt;br /&gt;
        ClientSize = new Size(240, 80);&lt;br /&gt;
        Button btn = new Button();&lt;br /&gt;
        btn.Parent = this;&lt;br /&gt;
        btn.Text = &amp;quot;good!&amp;quot;;&lt;br /&gt;
        btn.Size = new Size(17 * 4, 14);&lt;br /&gt;
        btn.Location = new Point((ClientSize.Width - btn.Width) / 2,&lt;br /&gt;
                                 (ClientSize.Height - btn.Height) / 2);&lt;br /&gt;
        AutoScaleDimensions = new Size(4, 8);&lt;br /&gt;
        AutoScaleMode = AutoScaleMode.Font;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Button Background Color==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;        &lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class ButtonBackColor : Form&lt;br /&gt;
{&lt;br /&gt;
  Button btn;&lt;br /&gt;
  public ButtonBackColor()&lt;br /&gt;
  {&lt;br /&gt;
        Text = &amp;quot;Button Properties&amp;quot;;&lt;br /&gt;
    Size = new Size(300,200);&lt;br /&gt;
    btn = new Button();&lt;br /&gt;
    btn.Parent = this;&lt;br /&gt;
    btn.Text = &amp;quot;text&amp;quot;;&lt;br /&gt;
    btn.Location = new Point(10,10);&lt;br /&gt;
    btn.BackColor = Color.LightGreen;&lt;br /&gt;
    &lt;br /&gt;
    f(btn);&lt;br /&gt;
  }&lt;br /&gt;
  static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Application.Run(new ButtonBackColor());&lt;br /&gt;
  }&lt;br /&gt;
  private void f(Button btn)&lt;br /&gt;
  {&lt;br /&gt;
    int xSize = 100;&lt;br /&gt;
    int ySize = 100;&lt;br /&gt;
    btn.Size = new Size(xSize, ySize);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Button Flat Style==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class ButtonFlatStyle : Form&lt;br /&gt;
{&lt;br /&gt;
  Button btn;&lt;br /&gt;
  int i = 1;&lt;br /&gt;
  FlatStyle[] flatStyles;&lt;br /&gt;
  Image img;&lt;br /&gt;
  public ButtonFlatStyle()&lt;br /&gt;
  {&lt;br /&gt;
        Text = &amp;quot;Button Properties&amp;quot;;&lt;br /&gt;
    Size = new Size(300,200);&lt;br /&gt;
    img = Image.FromFile(&amp;quot;YourFile.bmp&amp;quot;);&lt;br /&gt;
    btn = new Button();&lt;br /&gt;
    btn.Parent = this;&lt;br /&gt;
    btn.Text = btn.FlatStyle.ToString();&lt;br /&gt;
    btn.Location = new Point(10,10);&lt;br /&gt;
    btn.Click += new System.EventHandler(btn_Click);&lt;br /&gt;
    btn.Image = img;&lt;br /&gt;
    ButtonSize(btn);&lt;br /&gt;
    FlatStyle theEnum = new FlatStyle();&lt;br /&gt;
    flatStyles = (FlatStyle[])Enum.GetValues(theEnum.GetType());&lt;br /&gt;
  }&lt;br /&gt;
  static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Application.Run(new ButtonFlatStyle());&lt;br /&gt;
  }&lt;br /&gt;
  private void btn_Click(object sender, EventArgs e)&lt;br /&gt;
  {&lt;br /&gt;
    Button btn = (Button)sender;&lt;br /&gt;
    btn.FlatStyle = flatStyles[i];&lt;br /&gt;
    btn.Text = btn.FlatStyle.ToString();&lt;br /&gt;
    ButtonSize(btn);&lt;br /&gt;
    if (i &amp;lt; flatStyles.Length - 1)&lt;br /&gt;
      i++;&lt;br /&gt;
    else&lt;br /&gt;
      i = 0;&lt;br /&gt;
  }&lt;br /&gt;
  private void ButtonSize(Button btn)&lt;br /&gt;
  {&lt;br /&gt;
    int xSize = ((int)(Font.Height * .75) * btn.Text.Length) + (img.Width * 2);&lt;br /&gt;
    int ySize = img.Height * 2;&lt;br /&gt;
    btn.Size = new Size(xSize, ySize);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Button Image==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class ButtonImage : Form&lt;br /&gt;
{&lt;br /&gt;
  Button btn;&lt;br /&gt;
  Image img;&lt;br /&gt;
  public ButtonImage()&lt;br /&gt;
  {&lt;br /&gt;
        Text = &amp;quot;Button Properties&amp;quot;;&lt;br /&gt;
    Size = new Size(300,200);&lt;br /&gt;
    img = Image.FromFile(&amp;quot;YourFile.bmp&amp;quot;);&lt;br /&gt;
    btn = new Button();&lt;br /&gt;
    btn.Parent = this;&lt;br /&gt;
    btn.Text = &amp;quot;test&amp;quot;;&lt;br /&gt;
    btn.Location = new Point(10,10);&lt;br /&gt;
    &lt;br /&gt;
      btn.Image = img;&lt;br /&gt;
    ButtonSize(btn);&lt;br /&gt;
  }&lt;br /&gt;
  static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Application.Run(new ButtonImage());&lt;br /&gt;
  }&lt;br /&gt;
  private void ButtonSize(Button btn)&lt;br /&gt;
  {&lt;br /&gt;
    int xSize = 100;&lt;br /&gt;
    int ySize = 100;&lt;br /&gt;
    btn.Size = new Size(xSize, ySize);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Button mouse event==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
partial class Form1 : Form&lt;br /&gt;
{&lt;br /&gt;
    public Form1()&lt;br /&gt;
    {&lt;br /&gt;
        InitializeComponent();&lt;br /&gt;
    }&lt;br /&gt;
    private void button1_MouseEnter(object sender, EventArgs e)&lt;br /&gt;
    {&lt;br /&gt;
        button1.Text = &amp;quot;The mouse is over me&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    private void button1_MouseLeave(object sender, EventArgs e)&lt;br /&gt;
    {&lt;br /&gt;
        button1.Text = &amp;quot;The mouse is not over me&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    private void button1_Click(object sender, EventArgs e)&lt;br /&gt;
    {&lt;br /&gt;
        Button clickedButton = sender as Button;&lt;br /&gt;
        if (clickedButton != null)&lt;br /&gt;
        {&lt;br /&gt;
            clickedButton.Text = &amp;quot;I was clicked&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
partial class Form1&lt;br /&gt;
{&lt;br /&gt;
    private void InitializeComponent()&lt;br /&gt;
    {&lt;br /&gt;
        this.button1 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.button2 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.SuspendLayout();&lt;br /&gt;
        // &lt;br /&gt;
        // button1&lt;br /&gt;
        // &lt;br /&gt;
        this.button1.Location = new System.Drawing.Point(86, 89);&lt;br /&gt;
        this.button1.Name = &amp;quot;button1&amp;quot;;&lt;br /&gt;
        this.button1.Size = new System.Drawing.Size(172, 86);&lt;br /&gt;
        this.button1.TabIndex = 0;&lt;br /&gt;
        this.button1.Text = &amp;quot;button1&amp;quot;;&lt;br /&gt;
        this.button1.MouseLeave += new System.EventHandler(this.button1_MouseLeave);&lt;br /&gt;
        this.button1.Click += new System.EventHandler(this.button1_Click);&lt;br /&gt;
        this.button1.MouseEnter += new System.EventHandler(this.button1_MouseEnter);&lt;br /&gt;
        // &lt;br /&gt;
        // button2&lt;br /&gt;
        // &lt;br /&gt;
        this.button2.Location = new System.Drawing.Point(69, 25);&lt;br /&gt;
        this.button2.Name = &amp;quot;button2&amp;quot;;&lt;br /&gt;
        this.button2.Size = new System.Drawing.Size(75, 23);&lt;br /&gt;
        this.button2.TabIndex = 1;&lt;br /&gt;
        this.button2.Text = &amp;quot;button2&amp;quot;;&lt;br /&gt;
        // &lt;br /&gt;
        // Form1&lt;br /&gt;
        // &lt;br /&gt;
        this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);&lt;br /&gt;
        this.ClientSize = new System.Drawing.Size(292, 266);&lt;br /&gt;
        this.Controls.Add(this.button2);&lt;br /&gt;
        this.Controls.Add(this.button1);&lt;br /&gt;
        this.Name = &amp;quot;Form1&amp;quot;;&lt;br /&gt;
        this.Text = &amp;quot;Form1&amp;quot;;&lt;br /&gt;
        this.ResumeLayout(false);&lt;br /&gt;
    }&lt;br /&gt;
    private System.Windows.Forms.Button button1;&lt;br /&gt;
    private System.Windows.Forms.Button button2;&lt;br /&gt;
}&lt;br /&gt;
public class ButtonMouseEvent&lt;br /&gt;
{&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Application.Run(new Form1());&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Button PerformClick Method==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class ButtonEvent : Form&lt;br /&gt;
{&lt;br /&gt;
  Button btn1;&lt;br /&gt;
  Button btn2;&lt;br /&gt;
  public ButtonEvent()&lt;br /&gt;
  {&lt;br /&gt;
        Size = new Size(200,100);&lt;br /&gt;
    btn1 = new Button();&lt;br /&gt;
    btn1.Parent = this;&lt;br /&gt;
    btn1.Text = &amp;quot;Button1&amp;quot;;&lt;br /&gt;
    btn1.Location = new Point(10,10);&lt;br /&gt;
    btn1.Click += new System.EventHandler(btn1_Click);&lt;br /&gt;
    btn2 = new Button();&lt;br /&gt;
    btn2.Parent = this;&lt;br /&gt;
    btn2.Text = &amp;quot;Button2&amp;quot;;&lt;br /&gt;
    btn2.Location = new Point(100,10);&lt;br /&gt;
    btn2.Click += new System.EventHandler(btn2_Click);&lt;br /&gt;
  }&lt;br /&gt;
  static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Application.Run(new ButtonEvent());&lt;br /&gt;
  }&lt;br /&gt;
  private void btn1_Click(object sender, EventArgs e)&lt;br /&gt;
  {&lt;br /&gt;
    MessageBox.Show(&amp;quot;Button1 clicked.&amp;quot;);&lt;br /&gt;
    btn2.PerformClick();&lt;br /&gt;
  }&lt;br /&gt;
  private void btn2_Click(object sender, EventArgs e)&lt;br /&gt;
  {&lt;br /&gt;
    MessageBox.Show(&amp;quot;Button2 clicked.&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Button Style: image button, standard button==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
public class ButtonStyle : System.Windows.Forms.Form&lt;br /&gt;
{&lt;br /&gt;
  private System.ruponentModel.Container components = null;&lt;br /&gt;
  private System.Windows.Forms.Button btnImage;&lt;br /&gt;
  private System.Windows.Forms.Button btnStandard;&lt;br /&gt;
  private System.Windows.Forms.Button btnPopup;&lt;br /&gt;
  private System.Windows.Forms.Button btnFlat;&lt;br /&gt;
  // Hold the current text alignment&lt;br /&gt;
  ContentAlignment currAlignment = ContentAlignment.MiddleCenter;&lt;br /&gt;
  int currEnumPos = 0;&lt;br /&gt;
  public ButtonStyle()&lt;br /&gt;
  {&lt;br /&gt;
    InitializeComponent();&lt;br /&gt;
    // Set btnStandard as default accept.&lt;br /&gt;
    this.AcceptButton = btnStandard;&lt;br /&gt;
    CenterToScreen();&lt;br /&gt;
  }&lt;br /&gt;
  protected override void Dispose( bool disposing )&lt;br /&gt;
  {&lt;br /&gt;
    if( disposing )&lt;br /&gt;
    {&lt;br /&gt;
      if (components != null) &lt;br /&gt;
      {&lt;br /&gt;
        components.Dispose();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    base.Dispose( disposing );&lt;br /&gt;
  }&lt;br /&gt;
  #region Windows Form Designer generated code&lt;br /&gt;
  private void InitializeComponent()&lt;br /&gt;
  {&lt;br /&gt;
    &lt;br /&gt;
    this.btnStandard = new System.Windows.Forms.Button();&lt;br /&gt;
    this.btnFlat = new System.Windows.Forms.Button();&lt;br /&gt;
    this.btnImage = new System.Windows.Forms.Button();&lt;br /&gt;
    this.btnPopup = new System.Windows.Forms.Button();&lt;br /&gt;
    this.SuspendLayout();&lt;br /&gt;
    // &lt;br /&gt;
    // btnStandard&lt;br /&gt;
    // &lt;br /&gt;
    this.btnStandard.Font = new System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12F);&lt;br /&gt;
    this.btnStandard.ForeColor = System.Drawing.SystemColors.ControlText;&lt;br /&gt;
    this.btnStandard.Location = new System.Drawing.Point(16, 80);&lt;br /&gt;
    this.btnStandard.Name = &amp;quot;btnStandard&amp;quot;;&lt;br /&gt;
    this.btnStandard.Size = new System.Drawing.Size(312, 88);&lt;br /&gt;
    this.btnStandard.TabIndex = 2;&lt;br /&gt;
    this.btnStandard.Text = &amp;quot;I am a standard button&amp;quot;;&lt;br /&gt;
    this.btnStandard.Click += new System.EventHandler(this.btnStandard_Click);&lt;br /&gt;
    // &lt;br /&gt;
    // btnFlat&lt;br /&gt;
    // &lt;br /&gt;
    this.btnFlat.FlatStyle = System.Windows.Forms.FlatStyle.Flat;&lt;br /&gt;
    this.btnFlat.ForeColor = System.Drawing.Color.Blue;&lt;br /&gt;
    this.btnFlat.Location = new System.Drawing.Point(16, 24);&lt;br /&gt;
    this.btnFlat.Name = &amp;quot;btnFlat&amp;quot;;&lt;br /&gt;
    this.btnFlat.Size = new System.Drawing.Size(152, 32);&lt;br /&gt;
    this.btnFlat.TabIndex = 0;&lt;br /&gt;
    this.btnFlat.Text = &amp;quot;I am flat...&amp;quot;;&lt;br /&gt;
    // &lt;br /&gt;
    // btnImage&lt;br /&gt;
    // &lt;br /&gt;
    this.btnImage.BackgroundImage = new Bitmap(&amp;quot;YourFile.bmp&amp;quot;);&lt;br /&gt;
    this.btnImage.Font = new System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 20F, System.Drawing.FontStyle.Bold);&lt;br /&gt;
    this.btnImage.ForeColor = System.Drawing.Color.Black;&lt;br /&gt;
    this.btnImage.Location = new System.Drawing.Point(16, 192);&lt;br /&gt;
    this.btnImage.Name = &amp;quot;btnImage&amp;quot;;&lt;br /&gt;
    this.btnImage.Size = new System.Drawing.Size(312, 72);&lt;br /&gt;
    this.btnImage.TabIndex = 3;&lt;br /&gt;
    this.btnImage.Text = &amp;quot;Image Button&amp;quot;;&lt;br /&gt;
    this.btnImage.TextAlign = System.Drawing.ContentAlignment.TopCenter;&lt;br /&gt;
    // &lt;br /&gt;
    // btnPopup&lt;br /&gt;
    // &lt;br /&gt;
    this.btnPopup.FlatStyle = System.Windows.Forms.FlatStyle.Popup;&lt;br /&gt;
    this.btnPopup.ForeColor = System.Drawing.SystemColors.ControlText;&lt;br /&gt;
    this.btnPopup.Location = new System.Drawing.Point(176, 24);&lt;br /&gt;
    this.btnPopup.Name = &amp;quot;btnPopup&amp;quot;;&lt;br /&gt;
    this.btnPopup.Size = new System.Drawing.Size(152, 32);&lt;br /&gt;
    this.btnPopup.TabIndex = 1;&lt;br /&gt;
    this.btnPopup.Text = &amp;quot;I am a Popup!&amp;quot;;&lt;br /&gt;
    // &lt;br /&gt;
    // ButtonStyle&lt;br /&gt;
    // &lt;br /&gt;
    this.AcceptButton = this.btnStandard;&lt;br /&gt;
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
    this.ClientSize = new System.Drawing.Size(340, 269);&lt;br /&gt;
    this.Controls.Add(this.btnImage);&lt;br /&gt;
    this.Controls.Add(this.btnStandard);&lt;br /&gt;
    this.Controls.Add(this.btnPopup);&lt;br /&gt;
    this.Controls.Add(this.btnFlat);&lt;br /&gt;
    this.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;&lt;br /&gt;
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;&lt;br /&gt;
    this.Name = &amp;quot;ButtonStyle&amp;quot;;&lt;br /&gt;
    this.Text = &amp;quot;Buttons&amp;quot;;&lt;br /&gt;
    this.ResumeLayout(false);&lt;br /&gt;
  }&lt;br /&gt;
  #endregion&lt;br /&gt;
  &lt;br /&gt;
  protected void btnStandard_Click (object sender, System.EventArgs e)&lt;br /&gt;
  {      &lt;br /&gt;
    Array values = Enum.GetValues(currAlignment.GetType());&lt;br /&gt;
  &lt;br /&gt;
    currEnumPos++;&lt;br /&gt;
    if(currEnumPos &amp;gt;= values.Length)&lt;br /&gt;
      currEnumPos = 0;&lt;br /&gt;
    &lt;br /&gt;
    currAlignment = (ContentAlignment)ContentAlignment.Parse(currAlignment.GetType(), values.GetValue(currEnumPos).ToString());&lt;br /&gt;
    btnStandard.TextAlign = currAlignment;&lt;br /&gt;
    btnStandard.Text = currAlignment.ToString();&lt;br /&gt;
    btnImage.ImageAlign = currAlignment;&lt;br /&gt;
  }&lt;br /&gt;
  [STAThread]&lt;br /&gt;
  public static void Main(string[] args) &lt;br /&gt;
  {&lt;br /&gt;
    Application.Run(new ButtonStyle());&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Button Text Alignment==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class ButtonTextAlign : Form&lt;br /&gt;
{&lt;br /&gt;
  Button btn;&lt;br /&gt;
  public ButtonTextAlign()&lt;br /&gt;
  {&lt;br /&gt;
        Text = &amp;quot;Button Properties&amp;quot;;&lt;br /&gt;
    Size = new Size(300,200);&lt;br /&gt;
    btn = new Button();&lt;br /&gt;
    btn.Parent = this;&lt;br /&gt;
    btn.Text = &amp;quot;text&amp;quot;;&lt;br /&gt;
    btn.Location = new Point(10,10);&lt;br /&gt;
    btn.BackColor = Color.LightGreen;&lt;br /&gt;
&lt;br /&gt;
    btn.TextAlign = ContentAlignment.MiddleLeft;&lt;br /&gt;
    &lt;br /&gt;
    f(btn);&lt;br /&gt;
  }&lt;br /&gt;
  static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Application.Run(new ButtonTextAlign());&lt;br /&gt;
  }&lt;br /&gt;
  private void f(Button btn)&lt;br /&gt;
  {&lt;br /&gt;
    int xSize = 100;&lt;br /&gt;
    int ySize = 100;&lt;br /&gt;
    btn.Size = new Size(xSize, ySize);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Calculate Button size based on its Text==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class ButtonSize : Form&lt;br /&gt;
{&lt;br /&gt;
  Button btn;&lt;br /&gt;
  public ButtonSize()&lt;br /&gt;
  {&lt;br /&gt;
        Text = &amp;quot;Button Properties&amp;quot;;&lt;br /&gt;
    Size = new Size(300,200);&lt;br /&gt;
    btn = new Button();&lt;br /&gt;
    btn.Parent = this;&lt;br /&gt;
    btn.Text = &amp;quot;text&amp;quot;;&lt;br /&gt;
    btn.Location = new Point(10,10);&lt;br /&gt;
    f(btn);&lt;br /&gt;
  }&lt;br /&gt;
  static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Application.Run(new ButtonSize());&lt;br /&gt;
  }&lt;br /&gt;
  private void f(Button btn)&lt;br /&gt;
  {&lt;br /&gt;
    int xSize = 100;&lt;br /&gt;
    int ySize = 100;&lt;br /&gt;
    btn.Size = new Size(xSize, ySize);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Device Independent Button==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
class MyClass: Form&lt;br /&gt;
{&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Application.Run(new MyClass());&lt;br /&gt;
    }&lt;br /&gt;
    public MyClass()&lt;br /&gt;
    {&lt;br /&gt;
        int fontHeight = Font.Height;&lt;br /&gt;
        ClientSize = new Size(fontHeight * 30, fontHeight * 10);&lt;br /&gt;
        Button btn = new Button();&lt;br /&gt;
        btn.Parent = this;&lt;br /&gt;
        btn.Text = &amp;quot;Button&amp;quot;;&lt;br /&gt;
        btn.Size = new Size(17 * fontHeight / 2, 7 * fontHeight / 4);&lt;br /&gt;
        btn.Location = new Point((ClientSize.Width - btn.Width) / 2,&lt;br /&gt;
                                 (ClientSize.Height - btn.Height) / 2);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==extends Button==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
class MessageButtonDemo: Form&lt;br /&gt;
{&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Application.Run(new MessageButtonDemo());&lt;br /&gt;
    }&lt;br /&gt;
    public MessageButtonDemo()&lt;br /&gt;
    {&lt;br /&gt;
        MessageButton msgbtn = new MessageButton();&lt;br /&gt;
        msgbtn.Parent = this;&lt;br /&gt;
        msgbtn.Text = &amp;quot;Calculate&amp;quot;;&lt;br /&gt;
        msgbtn.MessageBoxText = &amp;quot;This button is not yet implemented!&amp;quot;;&lt;br /&gt;
        msgbtn.Location = new Point(50, 50);&lt;br /&gt;
        msgbtn.AutoSize = true;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class MessageButton: Button&lt;br /&gt;
{&lt;br /&gt;
    string str;&lt;br /&gt;
    public MessageButton()&lt;br /&gt;
    {&lt;br /&gt;
        Enabled = false;&lt;br /&gt;
    }&lt;br /&gt;
    public string MessageBoxText&lt;br /&gt;
    {&lt;br /&gt;
        set&lt;br /&gt;
        {&lt;br /&gt;
            str = value;&lt;br /&gt;
            Enabled = value != null &amp;amp;&amp;amp; value.Length &amp;gt; 3;&lt;br /&gt;
        }&lt;br /&gt;
        get&lt;br /&gt;
        {&lt;br /&gt;
            return str;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    protected override void OnClick(EventArgs args)&lt;br /&gt;
    {&lt;br /&gt;
        MessageBox.Show(MessageBoxText, Text);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Handle button messages==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Windows.Forms; &lt;br /&gt;
using System.Drawing; &lt;br /&gt;
 &lt;br /&gt;
class ButtonEventForm : Form { &lt;br /&gt;
  Button MyButton = new Button(); &lt;br /&gt;
 &lt;br /&gt;
  public ButtonEventForm() { &lt;br /&gt;
    Text = &amp;quot;Respond to a Button&amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
    MyButton = new Button(); &lt;br /&gt;
    MyButton.Text = &amp;quot;Press Here&amp;quot;; &lt;br /&gt;
    MyButton.Location = new Point(100, 200); &lt;br /&gt;
 &lt;br /&gt;
    // Add button event handler to list. &lt;br /&gt;
    MyButton.Click += MyButtonClick; &lt;br /&gt;
 &lt;br /&gt;
    Controls.Add(MyButton); &lt;br /&gt;
  }   &lt;br /&gt;
 &lt;br /&gt;
  [STAThread] &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ButtonEventForm skel = new ButtonEventForm(); &lt;br /&gt;
 &lt;br /&gt;
    Application.Run(skel); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Handler for MyButton. &lt;br /&gt;
  protected void MyButtonClick(object who, EventArgs e) { &lt;br /&gt;
    Console.WriteLine(&amp;quot;action.&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Relocate button after pressing button==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Windows.Forms; &lt;br /&gt;
using System.Drawing; &lt;br /&gt;
 &lt;br /&gt;
class ButtonEventFormLocation : Form { &lt;br /&gt;
  Button MyButton = new Button(); &lt;br /&gt;
 &lt;br /&gt;
  public ButtonEventFormLocation() { &lt;br /&gt;
    Text = &amp;quot;Respond to a Button&amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
    MyButton = new Button(); &lt;br /&gt;
    MyButton.Text = &amp;quot;Press Here&amp;quot;; &lt;br /&gt;
    MyButton.Location = new Point(100, 200); &lt;br /&gt;
 &lt;br /&gt;
    // Add button event handler to list. &lt;br /&gt;
    MyButton.Click += MyButtonClick; &lt;br /&gt;
 &lt;br /&gt;
    Controls.Add(MyButton); &lt;br /&gt;
  }   &lt;br /&gt;
 &lt;br /&gt;
  [STAThread] &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ButtonEventFormLocation skel = new ButtonEventFormLocation(); &lt;br /&gt;
 &lt;br /&gt;
    Application.Run(skel); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Handler for MyButton. &lt;br /&gt;
  protected void MyButtonClick(object who, EventArgs e) { &lt;br /&gt;
 &lt;br /&gt;
    if(MyButton.Top == 200) &lt;br /&gt;
      MyButton.Location = new Point(10, 10); &lt;br /&gt;
    else &lt;br /&gt;
      MyButton.Location = new Point(100, 200); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Set Label text in a button click event==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
public class ButtonActionSetLabelTextBox : System.Windows.Forms.Form&lt;br /&gt;
{&lt;br /&gt;
    private System.Windows.Forms.Label label1;&lt;br /&gt;
    private System.Windows.Forms.TextBox textBox1;&lt;br /&gt;
    private System.Windows.Forms.Button button1;&lt;br /&gt;
    private System.ruponentModel.Container components = null;&lt;br /&gt;
    public ButtonActionSetLabelTextBox()&lt;br /&gt;
    {&lt;br /&gt;
        InitializeComponent();&lt;br /&gt;
    }&lt;br /&gt;
    protected override void Dispose( bool disposing )&lt;br /&gt;
    {&lt;br /&gt;
        if( disposing )&lt;br /&gt;
        {&lt;br /&gt;
            if (components != null) &lt;br /&gt;
            {&lt;br /&gt;
                components.Dispose();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        base.Dispose( disposing );&lt;br /&gt;
    }&lt;br /&gt;
    #region Windows Form Designer generated code&lt;br /&gt;
    private void InitializeComponent()&lt;br /&gt;
    {&lt;br /&gt;
        this.label1 = new System.Windows.Forms.Label();&lt;br /&gt;
        this.textBox1 = new System.Windows.Forms.TextBox();&lt;br /&gt;
        this.button1 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.SuspendLayout();&lt;br /&gt;
        this.label1.Location = new System.Drawing.Point(32, 24);&lt;br /&gt;
        this.label1.Name = &amp;quot;label1&amp;quot;;&lt;br /&gt;
        this.label1.TabIndex = 0;&lt;br /&gt;
        this.label1.Text = &amp;quot;Hello World&amp;quot;;&lt;br /&gt;
        this.textBox1.Location = new System.Drawing.Point(24, 128);&lt;br /&gt;
        this.textBox1.Name = &amp;quot;textBox1&amp;quot;;&lt;br /&gt;
        this.textBox1.TabIndex = 1;&lt;br /&gt;
        this.textBox1.Text = &amp;quot;&amp;quot;;&lt;br /&gt;
        this.button1.Location = new System.Drawing.Point(24, 168);&lt;br /&gt;
        this.button1.Name = &amp;quot;button1&amp;quot;;&lt;br /&gt;
        this.button1.TabIndex = 2;&lt;br /&gt;
        this.button1.Text = &amp;quot;Say hello&amp;quot;;&lt;br /&gt;
        this.button1.Click += new System.EventHandler(this.button1_Click);&lt;br /&gt;
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
        this.ClientSize = new System.Drawing.Size(292, 266);&lt;br /&gt;
        this.Controls.AddRange(new System.Windows.Forms.Control[] {this.button1,&lt;br /&gt;
                                                                      this.textBox1,&lt;br /&gt;
                                                                      this.label1});&lt;br /&gt;
        this.Name = &amp;quot;ButtonActionSetLabelTextBox&amp;quot;;&lt;br /&gt;
        this.Text = &amp;quot;ButtonActionSetLabelTextBox&amp;quot;;&lt;br /&gt;
        this.ResumeLayout(false);&lt;br /&gt;
    }&lt;br /&gt;
    #endregion&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main() &lt;br /&gt;
    {&lt;br /&gt;
        Application.Run(new ButtonActionSetLabelTextBox());&lt;br /&gt;
    }&lt;br /&gt;
    private void button1_Click(object sender, System.EventArgs e)&lt;br /&gt;
    {&lt;br /&gt;
        label1.Text = &amp;quot;Hello &amp;quot; + textBox1.Text;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use delegate to add an event handler to a Button==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class ButtonEventDelegate : System.Windows.Forms.Form&lt;br /&gt;
{&lt;br /&gt;
  private Button btn;&lt;br /&gt;
  public ButtonEventDelegate()&lt;br /&gt;
  {&lt;br /&gt;
        Text = &amp;quot;Hello World&amp;quot;;&lt;br /&gt;
    btn = new Button();&lt;br /&gt;
    btn.Location = new Point(50,50);&lt;br /&gt;
    btn.Text = &amp;quot;Goodbye&amp;quot;;&lt;br /&gt;
    btn.Click += new System.EventHandler(btn_Click);&lt;br /&gt;
    Controls.Add(btn);&lt;br /&gt;
  }&lt;br /&gt;
  static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Application.Run(new ButtonEventDelegate());&lt;br /&gt;
  }&lt;br /&gt;
  private void btn_Click(object sender, EventArgs e)&lt;br /&gt;
  {&lt;br /&gt;
    Application.Exit();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>