Use C # to make a simple login interface

Source: Internet
Author: User


Drag the 1 Label controls from the toolbox on the left side to the design form, then copy the 1 label controls vertically, and then modify the Text property of the 2 label controls, respectively, to user name:, password.

Drag and drop two TextBox controls from the Toolbox to the right of the corresponding label control, TextBox2 (password) Properties PasswordChar the * password will be * hidden

Continue dragging two button controls from the Toolbox to the form, and change the "Text" property to "Login" and "Cancel" respectively.

Double-click the Login button control to automatically add the Click event, and then change the event code to the following:

private void Button1_Click (object sender, EventArgs e)
{
String name = TextBox1.Text;
string password = TextBox2.Text;
Name = name.     Trim (); A space does not affect
Password = password. Trim ();
if (name. Equals ("Zhansan") &&password. Equals ("1111"))
{/*messagebox.show ("welcome!"); */
Form2 f = new Form2 ();
F.show ();
This. Hide ();
}
Else
{MessageBox.Show ("false!");
}
}

Also double-click the Cancel button control with the mouse to automatically add the Click event, and then change the event code to the following:


private void Button2_Click (object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = null;
Textbox1.focus ();
This. Close ();
}





















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.