Picking a Control Class


There are several ways you can build objects that sit on a form at design time. Depending on the features you need, these objects can inherit from the Component, Control, and UserControl classes. They can also inherit from an existing control class such as a Button, TextBox, or ListView.

The Component class is the simplest of these classes. It doesn’t take up space on the form at design time, so it is appropriate when you don’t want an object that is visible to the user. If you want a class with properties that you can set at design time, but that should be invisible at runtime, build a Component.

The Control class is visible on the form at design and runtime but it is simpler than the UserControl class. Unlike a UserControl, it cannot contain constituent controls. If you want a control that draws itself without using any constituent controls, make your control inherit from the Control class.

The UserControl class is visible on the form at design and runtime. Unlike the Control class, it can contain constituent controls. If you want a control that uses constituent controls, make your control inherit from the UserControl class.

Finally, if some existing class provides some of the features that you need to use, make your control inherit from that class. The standard Visual Basic controls are very powerful and extensively tested, so you can save yourself a considerable amount of time by taking advantage of their existing features.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net