WinForm Student Information Management System homepage Design (2) _c# tutorial

Source: Internet
Author: User
Tags exit in

In the last Student login window design (WinForm Student Information Management system login Form Design (1)), the place to be modified is:

1, the maximum and minimize the login window, this General login window does not need, so we do not, click the Student Information Management system Form design find attribute maximizebox and attributes (Window maximized) and Minimizbox (window minimized) is true, Change them to false.

2, Login window design Properties AcceptButton it to determine the button's unique name (that is, button1), so we can also log on to the Student Information Management System home page after pressing ENTER.

3, after the login name of the TextBox1 control needs to enter the name of the login admin, and login password after the TextBox2 control needs to enter the lander's secret 123456, because the control property settings when the password is hidden as *, so we can not see.

To enter the student Information Management System home page also need to add a form under this windowsforms, right-click WindowsForms, select Add, select Windows Form, go to Add New Item dialog box, the name remains unchanged Form2, and finally click Add. Here we need to do a lot of things:

1. Change the Text property of the form to a student information management system, then change the property windowstate to maximized (for the first time to maximize it), and finally change the property IsMdiContainer (the form on the main page to the login window) to True.

2, you need to add a control menu bar to the form, in which we select the MenuStrip control, add the main menu item that you want to build, and the designer or administrator of the student management system is available to all modules, and if the student or teacher is unavailable to some modules, we'll do it later. Here we are designing this system as an administrator or designer, therefore, for all modules to be visible, the menu items that need to be added are: System management, performance management, course management, class management, student management, professional management, teacher management, and other menu items, such as forms, help, exit.

3, on the form also need to add StatusStrip control, the role of this control is the status bar, the status bar to change the property name Tssl_name.

4, add another toolbar on the form, that is, add the ToolStrip Control, the toolbar is placed under the menu bar, add a button control in the toolbar, click it will appear a new Subform dialog box, the subform we later add next.

5, to add the subform, just like adding a master page form, add another named children form, which we do not make any changes, simply to open it, to make the necessary instructions.

6, on the main page of the form of the menu bar exit, we click it needs to exit the entire program, which requires adding click events, we right-click the form to open the code, back to the main page of the form click to exit, find the Click event, double-click the back of the space back to code compiled write:

<span style= "FONT-SIZE:18PX;" >    
private void Exits Toolstripmenuitem_click (object sender, EventArgs e) 
    { 
      application.exit ();// Click Exit in main Menu we quit the entire program 
    }</span> 

7, in the added toolbar button control, we click it will appear as a subform named children, because the main page is an MDI form, so repeatedly click it to appear many of the subform named children, still the previous step as above, add the click event, the written code is:

<span style= "FONT-SIZE:18PX;" >    
private void Toolstripbutton1_click (object sender, EventArgs e) 
    { 
      Children qq = new Children ();// Create an instance of a subform 
      QQ. MdiParent = this;//requires the subform's parent form to be an MDI form 
      QQ. Show (); 
    } </span> 

This basically makes the home page form even after the design is complete.

The following is a connection login form and a master page form:

1, enter the information you write and then click the Login button to enter the homepage surface form, which requires the Click event to be added to the login form's OK button (button1), as well as the information entered in TextBox1, which is written as:

<span style= "FONT-SIZE:18PX;" >  
private void Button1_Click (object sender, EventArgs e) 
  { 
    string str = textbox1.text;// Get the information you entered in TextBox1 
    Form2 ad = new Form2 (str);//Create an object ad for the main interface of the Student information management system 
    . Show ()//Click OK to enter student information Management System main interface 
  }</span> 

2. Click the Cancel button (button2) in the login window to exit the entire program. Also add click event, write code as:

<span style= "FONT-SIZE:18PX;" >
private void Button2_Click (object sender, EventArgs e) 
{ 
  application.exit ();/Click Cancel to exit the entire program 
}< /SPAN> 

3. The information that is displayed in the status bar that we are adding to our homepage is to make some changes to the constructor in the form on the main page if you want to enter the information for us in the login window. Change the parameterless constructor to a constructor with a string type parameter, passing the argument to the property text of the status bar. The code written is:

<span style= "FONT-SIZE:18PX;" > Public    
Form2 (string s) 
    { 
      InitializeComponent (); 
      Tssl_name. Text = s; 
    } </span> 

4, we open the main Page form sometimes need to hide the login form, which requires the click of the OK button to hide the login form, in the first step of the code to add this. Hide () statement. So the complete code for step one is:

<span style= "FONT-SIZE:18PX;" >  
private void Button1_Click (object sender, EventArgs e) 
   { 
     string str = textbox1.text;// Get the information you entered in TextBox1 
     Form2 ad = new Form2 (str);//Create an object ad for the main interface of the Student information management system 
     . Show ()//Click OK to enter student information Management System main interface this 
     . Hide (),//Click to make sure that the login window is hidden 
   }</span> 

The problem here is that when you click the X button on the top right of the home page, you don't quit the entire program because it hides the login window, and if you exit the entire program, you need to click on the home page's own settings to exit, which is quitting the entire program.
Perform debugging, error modification and processing, the complete Form1 (login form) code is:

<span style= "FONT-SIZE:18PX;" >namespace windowsforms 
{public 
  partial class Form1:form 
  {public 
    Form1 () 
      { InitializeComponent (); 
    } 
 
    private void Button1_Click (object sender, EventArgs e) 
    { 
      string str = textbox1.text;//Get the information you entered in the TextBox1 
      Form2 ad = new Form2 (str);//Create an object ad for the main interface of the Student information management system 
      . Show ()//Click OK to enter student information Management System main interface this 
      . Hide (),//Click OK to hidden login window 
    } 
 
    private void Button2_Click (object sender, EventArgs e) 
    { 
      Application.exit ()//Click Cancel to exit the entire program 
    } 
  } 
}</span> 

The code for the complete master page form is:

<span style= "FONT-SIZE:18PX;" >namespace windowsforms 
{public 
  partial class Form2:form 
  {public 
    Form2 (string s) 
    { 
      InitializeComponent (); 
      Tssl_name. Text = s;//The information entered by the login window TextBox1 to the status bar Text property 
    } 
 
    private void Exit Toolstripmenuitem_click (object sender, EventArgs E 
    { 
      application.exit ()//Click Exit in Main Menu we exit the entire program 
    } 
 
    private void Menustrip1_itemclicked (object sender, ToolStripItemClickedEventArgs e) 
    { 
 
    } 
 
    private void Toolstripbutton1_click (object sender, EventArgs e) 
    { 
      Children qq = new Children ();//Create an instance of a subform 
      QQ. MdiParent = this;//requires the subform's parent form to be an MDI form 
      QQ. Show ();}} 
</span> 

You can find the location where you saved the program to open the program you built: run it, compare it to what you think it is, and then change it.

The above basic is the Student Information Management System homepage Construction, hoped that has the help to everybody's study.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.