An Example of Multiple Forms (Cont.)


To create another form, select the VS options:
   Project ⇒ Add Windows Form...
Pick the template “Windows Form” and give a form name such as Form2.cs:


A PictureBox is used to display the image. The keyword this provides a way to refer to the specific instance of a class or structure in which the code is currently executing.

01using System;
02using System.Windows.Forms;
03namespace WindowsFormsApp4 {
04  public partial class Happy : Form {
05    public Happy( ) { InitializeComponent( ); }
06 
07    private void Button1_Click( object sender, EventArgs e ) {
08      Form f = new Home( );
09      f.Show( );
10      this.Hide( );
11    }
12  }
13}