web123456

Winform study notes

WinformControls are reusable components, encapsulateduser interfaceFeatures and can be used for client Windows applications. Windows Forms not only provide many off-the-shelf controls, but also provides the infrastructure for self-developed controls. You can combine existing controls, expand existing controls, or create your ownCustom controls

WindowsFormCan be used to design forms and visual controls to create rich Windows-based applications. Provides a rich set of controls, and developers can define new controls that are unique to themselves.

A WinForm control refers to an object that enters or operates on data. For example, ComponentOne is a packaging of data and methods under the .net platform. Have its own attributes and methods. Properties are simple visitors to control data. The method is some simple and visible functions of the control. Windows included in the .NET FrameworkFormClasses are intended for GUI development. You can easily create command windows, buttons, menus, toolbars, and other screen elements that need to adapt to changing business needs.

Convenient data display and operation: One of the most common situations in application development isFormDisplay data on. WindowsFormProvides comprehensive support for database processing. You can access the data in the database andFormDisplay and operate data on.

Basic Features

1. Visualization;

2. Can interact with users, such as through keyboard and mouse;

3. Expose a set of attributes and methods for developers to use;

4. Expose a set of events for developers to use;

5. Persistence of control properties;

6. Publishable and reusable.

type

Similar to the development of MFC or API graphical interfaces, WinForm controls usually have three types:

1. Composite Controls:

Combine various existing controls to form a new control, which will centralize the controlperformanceFocus on.

2. Extended Controls:

A new control is derived from the controls of an existing control, adding new performance to the original control or changing the control power of the original control.

3. Custom Controls:

Derived directly from the class. The Control class provides all the introductory performance required by the control, including event handling for the keyboard and mouse. Custom controls are the most flexible and powerful method, but they also have high requirements for developers. You must write for the OnPaint event of the Control class.source code, you can also rewrite the WndProc method of the Control class to handle the underlying Windows messages, so you should learn GDI+ and Windows API.

Classification

1. Container classes: form, comboBox, Panel, etc.

2. Controls with user interface: appear in the form and are visible at runtime, such as button, label, textbox, etc.

3. Controls without user interface: Provide some functions in the background. For example toolTip

Commonly used controls:

1. User Interface (UI) Controls

Help completesoftwareDevelopment of interface elements such as windows, text boxes, buttons, and drop-down menus during development.

2. Chart controls

Help software implementationData visualization, realize complex charts that are difficult to complete independently during development. (ComponentOne Studio Chart for WinForm)

3. Report controls

Implement reports browsing, viewing, designing, editing, printing and other functions in the software. (ActiveReportswait)

4. Table (CELL) control

Mainly implements the functions of data processing and operation in the grid. (FlexGrid, Spread, etc.)

Control Development

Windows Forms controls are classes derived directly or indirectly. The base class of Windows Forms control isClientAppearance display in Windows applications provides the required avenue. Control provides a window handle that handles message routing and provides mouse and keyboard events and many other user interface events. Advanced layouts are also provided with specific properties for appearance display, such as ForeColor, BackColor, Height, Width, and many other properties. In addition, it provides security, threading support, and interactivity with ActiveX controls. Because the base class provides a lot of infrastructure, it is relatively simple to develop your own Windows Forms controls.

Creating a control is to design and create new controls by yourself.

Designing controls is a heavy task. There are huge differences between developing controls by yourself and using controls for visual program development, and the requirements areprogrammerproficientObject-oriented programming

Designing controls is hard work. For the developer of the control, the control is pureCode. In fact, creating new controls takes us back to the era of traditional development tools. Although this is a complexprocess, but it is also a once-for-all process.

The greatest significance of creating a control is to encapsulate duplicate work, and secondly, it can expand the functions of existing controls.

Control creationprocessIt includes design, development, debugging (the so-called 3Ds development process, namely Design, Develop, Debug), and then the use of controls.

The three main contents that control developers should master are: properties, events and methods.

Due to the high complexity of control development, many professional third-party controls inherit from certain base classes in .NET, rewritten or expanded some methods and attributes, so that some new functions can be realized. At the same time, they have great customization and can set different features according to the needs of users, so as to fully adapt to the needs of specific projects. Common third-party controls include table controls, report controls, user interface controls, etc.

Reference: Baidu Encyclopedia