Custom Drawing in Windows Forms
When you need to perform custom painting in Windows Forms, implement an event handler for the Paint event for Windows Forms controls. The Paint event is passed an object indicating which event raised the event and a second argument, PaintEventArgs. PaintEventArgs has a Graphics object property that is the Graphics object of the control that raised the event.
Listing 17.1 demonstrates an example where a form's Paint event is used to create a shadow effect for a string. If you find yourself writing a paint event handler to create custom effects, consider subclassing a control to make those custom paint effects permanent. (Refer to Chapter 16, “Designing User Interfaces,” for advanced topics.)
Additionally, Listing ...
Get Visual Basic® .NET Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.