Simple Windows login interface design and login interface design

Source: Internet
Author: User

Simple Windows login interface design and login interface design
Requirements: 1. the user name must be a letter.

1 // the user name must be 2 private void txtName_KeyPress (object sender, KeyPressEventArgs e) 3 {4 if (e. keyChar> = 'A' & e. keyChar <= 'Z') | (e. keyChar> = 'A' & e. keyChar <= 'Z') 5 {6 e. handled = false; 7} 8 else {9 MessageBox. show ("the user name can only be letters! "); 10 e. Handled = true; 11} 12}

 

2. When the cursor enters the text box, the background is blue and the text is white. When the cursor leaves the text box, the background is white and the text is black. Interface:
1 // when the cursor enters the text box, the background is blue and the font is white; 2 // when the cursor leaves the text box, the background is white and the font is black. 3 private void txtName_Enter (object sender, EventArgs e) 4 {5 txtName. foreColor = Color. white; 6 txtName. backColor = Color. blue; 7} 8 9 private void txtName_Leave (object sender, EventArgs e) 10 {11 txtName. backColor = Color. white; 12 txtName. foreColor = Color. black; 13}

 

3. after entering the username "admin" and password "123", click "OK". The system will pop up a message box to show that the entered information is correct. Otherwise, a message indicating incorrect username or password is displayed.

1 private void btnLogin_Click (object sender, EventArgs e) 2 {3 string userName = txtName. text; 4 string password = txtPwd. text; 5 if (userName = "admin" & password = "123") 6 {7 MessageBox. show ("welcome to the personal account management system! "," Login successful! ", MessageBoxButtons. OK, MessageBoxIcon. Information); 8} 9 else10 {11 MessageBox. Show (" the user name or password you entered is incorrect! "," Logon Failed! ", MessageBoxButtons. OK, MessageBoxIcon. Exclamation); 12} 13}

4. Click the cancel button to clear the input information and position the cursor in the txtName text box.

 

1   private void btnCancel_Click(object sender, EventArgs e)2         {3             txtName.Text = "";4             txtPwd.Text = "";5             txtName.Focus();6         }

 

5. Final interface: tip: Set the Image attribute for the label. to display the Image completely, set the AutoSize attribute of the label to false, and increase the label size appropriately. Note that the ImageAlign attribute is set to MiddleLeft, And the TextAlign attribute is set to MiddleRight.

Notice:

(1) ico: it is a type of icon file format for Windows. It can store Icon files with a single pattern, multiple sizes, and multi-color panels. (2) MessageBox: Message box. A modal dialog box is displayed, which contains a system icon, a group of buttons, and a brief message specific to the application, such as status or error. (3) The Shortcut Key of the Button is implemented by setting the Text attribute to "cancel (& C. (4) The software used for this exercise is Visual Studio 2012, and graphic resources are provided by VS. It is said that they can be found in the installation folder Common7 \ ImageLibrary of VS. If not, you can download them from the official website.

 

Related Article

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.