Inheriting from a UserControl that you've created

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If you design a UserControl (ie your class has line 2 as "Inherits System.Windows.Forms.UserControl"), is it then possible to inherit from this homemade user control to make more controls? If so how?

Thanks in advance

Crispin
 
Sure it is possible. You can do that as many times as you want. If you want to have a design time too you must do this: create the userControl and make sure it is a part of a class library (.dll). Then open a new project, right click the project and choose: new Inherited Form. This will open a dialog that will let you browse for the class library and once you find it you can choose which of the controls exposed you want to inherit. After you choose it you will see how it appears on the design time...

iulian
 
Hi Crispin,

Yes, you may inherit from your user control directly using the same way
like
Public Class MyControl
Inherits MyControlBase
...
EndClass
You may find more about Inheriting from controls in VisualBasic.NET in this
link:
<Walkthrough: Authoring a User Control with Visual Basic .NET>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbconwalkthroughcreatingcompositewfccontrol.asp

In WinForm, we have a new feature called Visual Inheritance which allows
you to see the controls on the base form and to add new controls. You may
read the walkthrough article about this feature at the link below:
<Walkthrough: Demonstrating Visual Inheritance>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbwlkwalkthroughdemonstratingvisualinheritance.asp

If you have any further questions on this issue, please feel free to reply
this thread.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
Back
Top