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.
|
|
|
|
|
using System;
using System.Windows.Forms;
namespace WindowsFormsApp4 {
public partial class Happy : Form {
public Happy( ) { InitializeComponent( ); }
private void Button1_Click( object sender, EventArgs e ) {
Form f = new Home( );
f.Show( );
this.Hide( );
}
}
}
|
“Argued that winning a silver medal is the worst,
as it means being the top loser.”
― Jerry Seinfeld
|