1th Lesson: C # Programming Fundamentals--a label control that moves

Source: Internet
Author: User

Reference: Learn about C # 24 lessons (Sheepskin Roll series)

1. tool:vs2017 (VS2008 VS2010 all Can)

2. New project: Windows Application Forms program, C #

3. In the Popup Form window, add a Label control (type text inside the property), three button control (in the attribute, named: demo, pause, cancel), a timer control (to control the scrolling and motion range of the label caption)

4. Rename the From1 to Frm_main, double-click each button to add the relevant properties; The implementation code is as follows:

usingSystem;usingSystem.Windows.Forms;namespacemovefontinform{ Public Partial classfrm_main:form {initializecomponet}Private voidButton1_Click (Objectsender, EventArgs e) {timer1. Enable=true; }       Private voidButton2_Click (Objectsender, EventArgs e) {timer1. Enable=false; }       Private voidButton3_Click (Objectsender, EventArgs e) {              This.       Close (); }}

5. Basic Knowledge Supplement:

(1) The Program.cs file is a class file for C # programs that is produced automatically when you create a console application or a Windows application. In the C # language, all class files are extended with CS;

(2) In addition, the main method is the entry method for all C # applications, that is, all C # programs begin running from the main method. In the main method, you can write C # code to be used when the program starts, usually in the Program.cs file;

(3) shortcut key to run: Ctrl+f5 start Execution (Start Debug mode: Automatically determine whether there are breakpoints or other tokens in the program); F5 starts (does not start debug mode: Completely ignores breakpoints or other tokens during the process of running the program);

(4) Interrupt the current operation of the program: SHIFT+F5 stop Debugging;

(5) Console.WriteLine ("Specify text to console output"): This statement outputs the specified text to the console, which is the string in double quotes; Console.ReadLine (): This statement is waiting to read the keyboard input, here to prevent the program Lee immediately exit;

(6) Set the program code line number: Menu Bar---------text editor--All languages--and line numbers;

(7) Font settings for controls in a unified form: example with a Button control. Create three button controls in the form, click any of the button controls, and then press CTRL and select the other two controls with the left mouse button, then right-click on any button, select the Properties command, and set its font in the pop-up Properties dialog box;

(8) Layout form via Format menu: The button control is still an example. Select the button control, and then, in the menu bar, select: Format----Horizontal spacing--same interval. (Other command functions, etc.);

(9)

1th Lesson: C # Programming Fundamentals--a label control that moves

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.