Add button to a form : Introduction « GUI « VB.Net Tutorial






Add button to a form
imports System
imports System.Drawing
imports System.Windows.Forms

namespace WinForms
  public class HelloWorld : inherits System.Windows.Forms.Form

    Private WithEvents btn as Button

    public sub New()
            Text = "Hello World"

      btn = new Button()
      btn.Location = new Point(50,50)
      btn.Text = "Goodbye"

      Controls.Add(btn)
    end sub

    public shared sub Main() 
      Application.Run(new HelloWorld())
    end sub

    private sub btn_Click(ByVal sender as object,ByVal e as EventArgs) Handles btn.Click
      Application.Exit()
    end sub
  end class
end namespace








14.1.Introduction
14.1.1.Your first Form window
14.1.2.Create Form by inheriting System.Windows.Forms.FormCreate Form by inheriting System.Windows.Forms.Form
14.1.3.Add button to a formAdd button to a form
14.1.4.Control Dock: Top, BottomControl Dock: Top, Bottom
14.1.5.Button PerformClick MethodButton PerformClick Method
14.1.6.Use With statement to set Form propertiesUse With statement to set Form properties
14.1.7.Essential elements of a Windows Forms application.
14.1.8.Using Controls in a Windows Forms Application