This rookie because of internship work, have to quickly contact the C # language, just good and do graduation design, so through self-study in the way double benefit to accomplish these two things.
Therefore, the text records or the code in the various filenames and so on is the graduation design for the template record, looking at inconvenient place please Haihan. (after all, the rookie of my temporarily can not write code special specification)
In the course of the study in a diary or weeks to record the way I met the problem and a variety of learning to consolidate, if there is like me the same-minded rookie, then we will exchange and learn from each other ~
Written records of the wrong or can be optimized place, if there is a great god see, but also want to be generous enlighten ~
Graduation design of the approximate model is similar to QQ chat, so apart first to get a login Windows Form login_interface (start do not know how to standardize naming, think up on Baidu, behind can put me pit miserable, embarrassed).
Initially basic also better learning, C # will be a lot of forms of functionality through simple settings and simple code (many functions can be Baidu to) become very easy to achieve, let me this rookie are good to get started.
1.windows form
I realized that the login interface is not maximized, just need to maximizebox in the lower right corner of the property to select false;
The other is backgroundimage set as a casual Baidu 2013 of the QQ background map;
2.TextBox controls
(A user name input, a password input all need this thing)
I want to implement in the textbox, the mouse is not clicked when the "Please enter the user name", the mouse click is empty, in order to enter information.
In the study I know this process is called focus, the process of the textbox to get focus is the mouse click Process, here you need to establish event enter and leave events.
private void Textbox_username_enter (object sender, EventArgs e) { //when the current control gets the focus, the text content becomes empty if (textbox_ Username.text = = "Please enter user name") { textbox_username.text = ""; Textbox_username.forecolor = Color.Black; } Sets the background color Textbox_username.backcolor = Color.beige When the current control gets focus ; } private void Textbox_username_leave (object sender, EventArgs e) { if (Textbox_username.text = = "") { textbox_username.text = "Please enter user name"; Textbox_password.forecolor = Color.Black; } When the current control loses focus, set the background color to white textbox_username.backcolor = Color.White; }
3.Button controls
Create a OK button and a Cancel button.
The user name and password are correctly entered into the user interface, if the error is displayed error message (The current knowledge of the wrong form of unification)
private void Button1_Click (object sender, EventArgs e) { if (Textbox_username.text = = "1" && textbox_ Password.text = = "1") {this . Close (); } else { MessageBox.Show ("username and password is wrong, please re-enter");} }
Cancel button to exit the program (emphasis on exit to confirm exit).
private void Button_cancel_click (object sender, EventArgs e) { if (MessageBox.Show ("What are you doing?") "," think clearly! ", Messageboxbuttons.yesno, messageboxicon.exclamation) = = Dialogresult.yes) { Environment.exit ( 0); } }
Such a basic login login interface Even if the basic completion of ~ ^w^ ~
Welcome you to enlighten me ~
C # language first lesson-windows form basic Functions (login login interface)