Previous | Index | Next 

Cancel and Default properties

The VB.NET Button control doesn’t support the Cancel or Default properties. Instead, you select which the default and cancel buttons on a form are by setting the form’s AcceptButton and CancelButton properties. Therefore, the following VB6 code:

        btnCancel.Cancel = True
        btnOK.Default = True

can be converted to VB.NET as follows:

        Me.CancelButton = btnCancel
        Me.AcceptButton = btnOK

Both the Upgrade Wizard and VB Migration Partner correctly migrate forms containing default and cancel buttons. However, only VB Migration Partner supports these properties when assigned in late-bound mode or when the button is located inside a usercontrol.

 

Previous | Index | Next