Button.Top : Button « System.Windows.Forms « C# / C Sharp by API






Button.Top

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

public class PushMe2 : Form {

  Button pushMeButton;

  public PushMe2() {
    pushMeButton = new Button(); 
    pushMeButton.Text = "Push Me";
    pushMeButton.Height = 60;
    pushMeButton.Width = 80;
    pushMeButton.Top = 60;
    pushMeButton.Left = 60;

    pushMeButton.Click += new EventHandler(ButtonClicked);

    this.Controls.Add(pushMeButton);

    this.Height = 200;
    this.Width = 200;
    this.StartPosition = FormStartPosition.CenterScreen;
    this.Visible = true;
  }

  public void ButtonClicked(object source, EventArgs e) {
    Button b = (Button)source;
    if ( b.Text == "Push Me" ) {
      b.Text = "Ouch";
    }
    else {
      b.Text = "Push Me";
    }
  }

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

   
    
  








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.PerformClick()
14.Button.Size
15.Button.Text
16.Button.TextAlign