Button.PerformClick() : Button « System.Windows.Forms « C# / C Sharp by API






Button.PerformClick()

 

using System;
using System.Drawing;
using System.Windows.Forms;

public class ButtonEvent : Form
{
  Button btn1;
  Button btn2;

  public ButtonEvent()
  {
        Size = new Size(200,100);

    btn1 = new Button();
    btn1.Parent = this;
    btn1.Text = "Button1";
    btn1.Location = new Point(10,10);
    btn1.Click += new System.EventHandler(btn1_Click);

    btn2 = new Button();
    btn2.Parent = this;
    btn2.Text = "Button2";
    btn2.Location = new Point(100,10);
    btn2.Click += new System.EventHandler(btn2_Click);
  }

  static void Main() 
  {
    Application.Run(new ButtonEvent());
  }

  private void btn1_Click(object sender, EventArgs e)
  {
    MessageBox.Show("Button1 clicked.");
    btn2.PerformClick();
  }

  private void btn2_Click(object sender, EventArgs e)
  {
    MessageBox.Show("Button2 clicked.");
  }
}

   
  








Related examples in the same category

1.new Button()
2.Button.Anchor
3.Button.Click
4.Button.DialogResult
5.Button.Dock
6.Button.FlatStyle
7.Button.Font
8.Button.Image
9.Button.Location
10.Button.MouseDown
11.Button.MouseEnter
12.Button.Parent
13.Button.Size
14.Button.Text
15.Button.TextAlign
16.Button.Top