This tutorial, you will learn how to create a program that will use mulitple forms. Basically, many programmers have many forms that are accessible from the main form that loads at start up. At this time, we’re ging to create a very simple application that has a single button. And hen this button is clicked, it loads the log in form. And this form looks like as shown below.
Next, we’re going to add another form. To do this, here’s the following steps:
1.Go to Solution Explorer
2.Right click project and select Add
3.Then Choose “Windows Form”
4.And it will automatically add a new form to your project.
The following steps looks like as shown below.
On the second form, let’s design looks like as shown below.
Next, let’s go back to our Form1 which is the first form that loads at start up.then double click the “Login” button and add the following code.
- Form2 loginForm;
- loginForm = new Form2();
And here’s all the code used in this application:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication3
- public partial class Form1 : Form
- public Form1()
- private void button1_Click(object sender, EventArgs e)
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.