Tutorials
VB.NET 2005
VB.NET Creating and Managing Components Part 2
VB.NET Creating and Managing Components Part 2 - Page 2
We have now added one property called ShadowColor and also have overridden the onTextChanged and onPaint methods.
Now we shall create a windows project in the Visual Studio. Right-click on the ToolBox to and click on “Choose Items ..”. A new dialog box to add control is shown. Navigate to the custom control that we have created and add the control. The control will be displayed in the ToolBox. We can now drag and drop this control on the Form. Now click F5 to see the result. The onTextChanged method and onPaint event which have been overridden have caused the visual effect to happen as shown by the screenshot below:
.
..

Component classes are inherited from System.ComponentModel.Component. By inheriting from this class, the application developer is provided with a good designer surface, like that of Forms designer. This designer is called component designer. Controls can be dragged and dropped on to this designer from the tools box.
This helps the developer build quicker and easier solutions. Server controls can be added rapidly to the solution. Let us now take a look how easily this can be done.

The application developer can Drag and drop any component to the class from the ToolBox and extend the facility or he can open the code view and author a new component altogether.
Click on the code view. Now add the following lines of code to the class:
The instance initialization parameters are shown in the member variables. Only InstanceID is declared as public.
One property is defined to return the value of ClassInstanceCount. The Finalize method is overridden to decrement the value of ClassInstanceCount. Now the developer can build the solution to make it available for the being consumed. This can be imported to the toolbox and used by dragging and dropping.
Now press F 5 to execute the program. The output is shown below:
|
The Screen shot at start up showing the instance number |
The screen shot after pressing the button |
|
|
|
First Page: VB.NET Creating and Managing Components Part 2
|
While the article addresses many components - I find some things are lacking - such as creating html components with no closing end tag such as these are not created with the generic control - so how do you build them ?? |