WinForm Fundamentals of C #

Source: Internet
Author: User

WinForm Overview

A Windows Form (WinForm) is a window that can be used to provide information and accept its input. Typically, you build a Windows Forms application by adding controls to the form and developing responses to user actions. A "control" is a relatively independent user interface (UI) element that displays data or accepts data input. Windows Forms is a smart client technology for the. NET framework that enables you to create Windows Forms smart client applications when you use the IDE development environment for VS 2012.

WinForm The creation of the program

The creation of the new and console applications for the WinForm program is the same, except that the Windows Forms application is selected when the template is selected, as shown in the following:

1. After you open VS2012, click File, click New, and then click Project to bring up a dialog box for the new project.

2, in the New Project dialog box, select Windows under C # in the template, click Windows Forms Application, rename, change save path, and finally click OK to complete the creation of the Windows Forms application.

form additions and deletions

The way to add a form is to right-click the solution on the left side of the main window, select Add, then select New Project, pop Up the dialog box for the new project that is still the same as when you created the new Windows Forms application, and add a new form to the project when you are finished.

You can delete a form by right-clicking it from the name of the form you want to delete, and selecting the Delete command from the pop-up menu.

Common properties of a form

The form contains many properties, one of which is set by the Properties panel, one through the property palette, the property panel setting for the design-time setting for the form properties, the Set method to select the form and right-click to select the Properties command, or to select the Properties window in the view, or press the F4 function key.

1 Select the Properties command by selecting the form and right-clicking

2 Select the Properties window in the view

3vs2012 more humane in the Windows Forms application that you create, the property is in the lower right

Common events for forms

All events for a form can be viewed by clicking a lightning-like symbol in the Properties panel, which lists common events for the form. If you add an event to the form, simply select the event you want to add in the event panel, double-click in the space following it, and the corresponding event will be automatically generated.

form to add controls to the form to show and hide

For an application, a control is a building block for the user interface. They have interactive features, such as text boxes, buttons, and list boxes. The controls in VS2012 are placed in the Toolbox under the View in the main menu, and clicking on it will appear as the Toolbox dialog box is all the controls.

Forms are displayed and hidden through the show method and the Hide method, in the following format:

public void Show (); Show

public void Hide (); Hide

Use an example to show and hide (open another form in form Form1 via the button btnshow Form2) code:

<span style= "FONT-SIZE:18PX;" >        private void Btnshow_click (object sender, EventArgs e)        {            Form2 frm2 = new Form2 ();            Frm2. Show ();        } </span>

basic operations for controls in a form

When controls are added to a form, users can manipulate them in a number of ways, such as aligning, resizing, ordering, adjusting spacing, and so on.

The order of the controls can be set at design time by selecting the controls you want to set, selecting the order under the format, and then clicking the put to bottom (or top-level) command to set.

The control's alignment action is designed with the SHIFT or CTRL feature to select multiple controls, select the Alignment command under formatting, and pop up the alignment menu. Choose the alignment that applies to you.

Using VS2012 is relatively easy, and the basic operations of these controls are set on their own when the control is selected.


WinForm Fundamentals of C #

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.