C # control Overview

Source: Internet
Author: User

C # control and common design

1. Form
1. common attributes
(1) Name attribute: used to obtain or set the Name of a form. In an application, the Name attribute can be used to reference a form.
(2) WindowState attribute: used to obtain or set the window state of a form. There are three types of values: Normal (Normal display of the form) and Minimized
(The form is displayed in the form of minimization) and Maximized (the form is displayed in the form of maximization ).
(3) StartPosition attribute: used to obtain or set the start position of the form during running.

(4) Text attribute: This attribute is a string attribute used to set or return the Text displayed in the title bar of the window.
(5) Width attribute: used to obtain or set the Width of the form.
(6) Height attribute: used to obtain or set the Height of the form.
(7) Left attribute: used to obtain or set the x coordinate of the Left edge of the form (in pixels ).
(8) Top attribute: used to obtain or set the y coordinate of the upper edge of the form (in pixels ).
(9) ControlBox attribute: used to obtain or set a value that indicates whether the control box is displayed in the title bar of the form. The value is true.
The control box is displayed. If the value is false, the control box is not displayed.
(10) MaximizeBox attribute: used to obtain or set a value indicating whether to display the maximize button in the title bar of the form. Value
If the value is true, the maximum button is displayed. If the value is false, the maximum button is not displayed.
(11) MinimizeBox attribute: used to obtain or set a value indicating whether to display the minimization button in the title bar of the form. Value
If the value is true, the minimization button is displayed. If the value is false, the minimization button is not displayed.
(12) AcceptButton attribute: used to obtain or set a value. The value is the name of a button. When you press Enter
Click the button on the form.
(13) CancelButton attribute: This attribute is used to obtain or set a value. The value is the name of a button. It is equivalent
Click the button on the form.
(14) Modal attribute: This attribute is used to set whether the form has a mode display form. If the form is displayed in mode, the attribute value is
True; otherwise, false. When the form is displayed in a mode, only objects in the mode form can be input. The Mode window must be hidden or closed.
Body (usually in response to a user operation) before entering another form. Forms with mode display are usually used in applications.
Dialog box.
(15) ActiveControl attribute: used to obtain or set the Active Control in the container control. A form is also a container control.
(16) ActiveMdiChild attribute: used to obtain the current active subwindow of the Multi-Document Interface (MDI.
(17) AutoScroll attribute: used to obtain or set a value that indicates whether the form is automatically rolled. If this attribute value is set
True, when any control is outside the work area of the form, the scroll bar is displayed on the form. In addition, when auto-scroll is enabled, the form
To make the control with the input focus visible.
(18) BackColor attribute: used to obtain or set the background color of the form.
(19) BackgroundImage attribute: used to obtain or set the background image of the form.
(20) Enabled attribute: used to obtain or set a value that indicates whether the control can respond to user interaction. If the widget can

To respond to user interaction, true; otherwise, false. The default value is true.
(21) Font attribute: used to obtain or set the Font of the text displayed by the control.
(22) ForeColor attribute: used to obtain or set the foreground color of the control.
(23) IsMdiChild attribute: gets a value indicating whether the form is a multi-Document Interface (MDI) subform. When the value is true,
Is a child form. If the value is false, it is not a child form.
(24) IsMdiContainer attribute: gets or sets a value indicating whether the form is a multi-Document Interface (MDI)
Container. If the value is true, it is a sub-form container. If the value is false, it is not a sub-form container.
(25) KeyPreview attribute: used to obtain or set a value, which indicates the form before passing a key event to a control with focus
Whether the event will be received. If the value is true, the form receives the button event. If the value is false, the form does not receive the button event.
(26) mdichil.pdf attribute: array attribute. Each element in the array uses this form as the parent multi-Document Interface (MDI) Sub-window.
Body.
(27) MdiParent attribute: used to obtain or set the current multi-Document Interface (MDI) parent form of the form.
(28) ShowInTaskbar attribute: used to obtain or set a value indicating whether to display a form in the Windows taskbar.
(29) Visible attribute: used to obtain or set a value that indicates whether the form or control is displayed. The value is true.
Display form or control, false is not displayed.
(30) Capture property: If this property value is true, the mouse will be limited to the response of this control, regardless of whether the mouse is in this control
.
2. Common Methods
The following describes the most common methods for forms.
(1) Show method: This method is used to display the form. The call format is:
Form name. Show ();
The form name is the name of the form to be displayed.
(2) Hide method: This method is used to Hide the form. The call format is as follows:
Form name. Hide ();
The form name is the name of the form to be hidden.
(3) Refresh method: This method is used to Refresh and redraw the form. The call format is:
Form name. Refresh ();
The form name is the name of the form to be refreshed.
(4) Activate method: This method activates the form and gives it focus. The call format is:
Form name. Activate ();
The form name is the name of the form to be activated.
(5) Close method: This method is used to Close the form. The call format is:
Form name. Close ();
The form name is the name of the form to be closed.
(6) ShowDialog method: This method is used to display the form as a mode dialog box. The call format is:
Form name. ShowDialog ();
3. Common events
(1) Load event: This event occurs when the form is loaded to the memory, that is, before the first display of the form.
(2) Activated event: This event occurs when the form is Activated.
(3) Deactivate event: This event occurs when the form loses focus and becomes inactive.
(4) Resize event: This event occurs when the form size is changed.
(5) Paint event: This event occurs when the form is repainted.
(6) Click Event: This event occurs when the user clicks the form.

(7) DoubleClick event: This event occurs when you double-click a form.
(8) Closed event: This event occurs when the form is Closed.


Text Box controls

2. Label Control
1. common attributes:
(1) Text attribute: Used to set or return the Text information displayed in the label control.
(2) AutoSize attribute: used to obtain or set a value indicating whether to automatically adjust the size of the control to display its content completely. Fetch
When the value is true, the control is automatically adjusted to the size when it can accommodate the text. When the value is false, the control size is the designed size.
The default value is false.
(3) Anchor attribute: used to determine the fixed relationship between the control and its container control. The so-called container control refers to the following situation:
There is also a control in the control. For example, the most typical form control contains many controls, such as label controls and text boxes.
The control that contains the control is a container control or parent control, and the parent control is a child control. In this case, a problem occurs, that is, the Child control and the parent
Widget location relationship, that is, when the location and size of the parent widget change, the Child widget follows
The principle of changing its position and size. The Anchor attribute defines this principle.
For the Anchor attribute, you can set any number of Top, Bottom, Right, and Left attributes.
In the Properties window, click the arrow to the right of the Anchor attribute
In the window 9-6, you can set the Anchor attribute value. Figure 9-6 Selected

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.