Chapter 3:(Part-I) Creating New Project in Visual Studio

 

VB.NE

Chapter 3:(Part-I) Creating New Project in Visual Studio

Let’s start a new project called “School Management System”. Visual Studio will create a new project with a default Form and named it as Form1. Form1 will be the startup Form of our Project. We will soon changed it to MDIForm.

Let’s add an MDIFORM to our project from where we will control all our forms to load and handle data. Therefore, Right click on your project and choose Add -> New Item.

mdiform

This will open a new Dialog Box, Select MDI Parent Form from the list. Leave the default name as ” MDIParent1.vb” and click the Add Button to add the Mdi Form to our project.

mdiform1

Now click Project from the top Menu Bar in Visual Studio and click “School Management System Properties”

properties

Change the startup Form in the application to the ‘MDIParent1″

startupform

Now Double click the MDIParen1.vb in the solution explorer to open it in the design view. First of all, let’s delete the default Menubar and Toolbar strips. Now add a TabControl by dragging and dropping it from tools menu. Change the text of First Tab to Students Registration and that of Tab2 to examination. You can find text change property within the collection of Tabpages in properties windows. Now add a Menubar and Toolbar strips to this TabControl. We will use them later.

Now Drag and drop a panel to the left side of the MDI form. Add a Button to this pannel by dragging and dropping it from tools Box. Change the Text of the Button to the “Stdents Registeration”. Leave all the other default values like name etc as suggested by the visual studio. Your ultimate MDIform should look like as shown in the image below. Also make necessary changes to panel and buton to resize thats looks better to you.

mdi_design

Double click button1 i.e the “Students registeration button to open its code window and past the following code in it.

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.TabControl1.SelectedTab = Me.TabPage1
        For Each ChildForm As Form In Me.MdiChildren
            ChildForm.Close()
        Next
        ' Create and show the StudentRegistrationForm as a child form
        Dim studentRegistrationForm As New Form1()
        studentRegistrationForm.MdiParent = Me
        studentRegistrationForm.Dock = DockStyle.Fill

        studentRegistrationForm.Show()
    End Sub

In this example, we have a MainForm that serves as the MDIForm. It will have many buttons for different functionalities, such as student registration, examinations etc. When the user clicks on a menu item, the corresponding child form (e.g., StudentRegistrationForm, examinations) is created and shown as a child form of the MDIForm using the Show method. You can customize the design and functionality of the child forms to suit your application’s requirements. For the simplicity you should always keep in mind to close all the childforms if any is opened before opening a new form.

Now run the application and click the students registration button to load the child form. I have changed the background colour of the child form so that you understand that the childform has been loaded. The output is given as:

app_final

That’s all, You have completed the Part-I of this chapter. In the Part-II , we will design “Students Registeration form”, WE will also create our project database at run time and will create tables and fields necessary for the enrollment of students.

 

Leave a Reply

Your email address will not be published. Required fields are marked *