Differences between user controls and override controls

Source: Internet
Author: User

User Control: allows users to put multiple system controls together and contain relatedCode, Encapsulate it into a collection of controls, so that users can easily repeatedly call this collection. For example, when each form requires a user logon box (including Logon Name, logon password, and submit button), you can put these controls into a new user control, you can call this control on each form, without creating (or copying) A new Login Name, logon password, and submit button control on each form. This combination makes it easier for users to understand. It is equivalent to creating an abstract class.

 

Override controls: override controls generally inherit system controls and rewrite some of these methods as needed. The override control is an inherited encoding operation. The key is how to call and use the overwritten control? I searched a lot of webpages and did not find the relevant information. I did not find a way to drag and drop the control like a system control, but I dynamically instantiated the control and placed it in a form or control, yes. The sample code is as follows:

1:Gridviewcontrol maid =NewGridviewcontrol ();// Gridviewcontrol is a class that inherits from the datagridview class and overwrites some methods.

2:Datagridview1.location =NewPoint (10, 10 );// Set the widget location

3:Datagridview1.height = 500;// Define the widget size

4:Maid = 500;

5:Panel1.controls. Add (datagridview1 );// Load the control in Panel1 OF THE FORM

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.