Creating a Custom Control

Custom controls represent the ultimate in extensibility because they are built from scratch. As a result, they are relatively hard to develop because they require you to worry not only about functionality but also about every single aspect of the control’s visual appearance. Because the physical user interface of the custom control needs to be drawn 100% by custom code, a steep learning curve is associated with authoring a custom control.

Because much of the work that goes into creating a custom control is at the code level, we won’t try to tackle this subject with any useful degree of detail in this book. You should note, however, that the process starts the same way as with other control options: Visual Studio has a custom control project item template; adding this to your project gives you a baseline of code to start with. From there, it’s up to you.


Note

The Paint event is where you place the code to draw your control’s user interface. Although so-called “owner draw” controls can involve complex drawing code, the good news is that the Windows Forms Designer leverages whatever code you place in the Paint event to render the control at design time. This means that you can still rely on the Windows Forms Designer to provide you with a WYSIWYG experience even with custom controls.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset