Basic skills (01) ------- inheritance of forms

Source: Internet
Author: User

1. inherit the concept of a form

An inherited form is to create a new form based on the structure of the existing form. This process of inheriting from the existing form is called visual inheritance.

There are two ways to create an inherited form: programming and using an inherited selector to create an inherited form.

1) Create an inherited form by programming

· Create a new project and add a Windows form Form1.cs

· Add a TestBox, Lable, And Button control to it. The click Event of the Button is lable and displayed as the input information in the TextBox.

· Add a Windows Form Form2.cs to the project and modify the inherited base class in Form2.cs as Form -- "Form1

The result of Form2 is as follows:

In this case, double-click the button1 button and define the click event as green when the button is clicked. The effect is as follows:

When you do this, you may find that Form2 inherits from Form1, but the controls inherited from Form1 in Form2 do not allow you to modify or adjust the position, check that all attributes are gray and cannot be changed. You are very depressed. What is the purpose of inheritance?

The reason is that the Modifires attribute of each control in Form1 is Private by default. If you want to inherit a form to modify a control, set the Modifires attribute of the control to Public. Which of the following cannot be modified to Private? OK!

2) use the inheritance selector to inherit the form. Note that the inherited form must be converted into a dll file, and then reference this Dll file in the inherited form!

The specifics are not described here!

 

 

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.