C # "Merry" and similar "hamster" applet

Source: Internet
Author: User

Today, I mainly reviewed the form applet that I studied yesterday. It is mainly applied to some basic properties of the control.

Program:

Merry (requirements are: Use two forms, two forms to pass values, Form1 to Form2, the incoming string to scroll horizontally on the Form2 form)

* First is the Setup interface (TXTNAME,TXTPWD. The second text box txtname set its Usesystempasswordchar property to True,maxlength set to 6)

Text Box Properties: Usesystempasswordchar Indicates whether the text in the edit control is displayed with the default password character ("").
PasswordChar indicates that the displayed characters will be entered for the password of the single-line edit control. (You can enter any password characters you want to display, such as *,?) )

MAXLENGTH Specifies the maximum number of characters that can be entered in an edit control

Timer Control properties: Mainly set the Enabled property to True;interval (the frequency of the event, in milliseconds) is set to 500, this is mainly used to control the number of user login, if more than three times, wait 500 milliseconds before you can re-enter

Main code for the Form1 form:

private void Form1_activated (object sender, EventArgs e) {this.txtuser.Focus ();        } int i = 0; private void Btnlogin_click (object sender, EventArgs e) {string user = This.txtuser.Text.Trim            ();            string pwd = This.txtpwd.Text.Trim (); if (i>=3) {Btnlogin.            Enabled = false; } if (string.                IsNullOrEmpty (user) {MessageBox.Show ("username is incorrect, please re-enter");            ++i; } else if (string.                IsNullOrEmpty (pwd)) {MessageBox.Show ("Password cannot be empty, please re-enter");                            ++i; } Form2 FM = new FORM2 (user);
Fm. Show ();
This. Hide ();//Hidden form
}} private void Timer1_Tick (object sender, EventArgs e) {btnlogin. Enabled = true; }

Form2 The interface of the form, define a label control to receive the value (username) from Form1

Here the Timer control acts to control the speed of string scrolling.

The code is:

       String name = String. Empty;        Public Form2 (string users)               {            InitializeComponent ();            Name  = users + "Hello, Welcome to China   ";        }        private void Timer1_Tick (object sender, EventArgs e)                {            name = name. Substring (1) + name. Substring (0, 1);            This.lblname.Text = name;                   }        private void btnClose_Click (object sender, EventArgs e)                {this            . Close ();        }

implementation results:

A little program like "hit The Hamster"

Form initial interface, added a button.

Main code:

Run effect

Well, today is the first time to learn here, after two days of learning that the Windows Form form program is simpler than the console, probably because in school we basically go to school in the form by dragging the controls to complete some of the small programs, rarely learn the console program. Because of this, I will try to learn more. Come on, enze!.

C # "Merry" and similar "hamster" applet

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.