Overriding Base Methods Using the Visual Basic Code Editor
When working with Visual Basic classes in Windows Forms, you may need to override a method defined in a base class. In addition to providing a way to create event handlers while writing code, the Visual Basic Code Editor also allows you to override methods contained in your base class.
To override a base class method using the Visual Basic Code Editor
- Open the form that you want to use in the Code Editor.
- From the Class Name drop-down list at the top of the Code Editor, choose (Overrides).
A list of the methods is added to the Event list.
- From the Method Name list at the top of the Code Editor, choose the method for which you want to create an event handler.
A method is added to your form's class and the Overrides keyword is added to the method signature. The following code demonstrates an example of an overridden form method:
' Visual Basic Protected Overrides Sub Finalize() 'Implementation Code Added Here End Sub