Visual Basic Concepts
Default and cancel buttons are controlled by the container. To notify the container that your control is capable of being a default or cancel button, set the DefaultCancel property of the UserControl to True.
If you have set the Default or Cancel property to True for one of the constituent controls on your UserControl, you must set the DefaultCancel property of the UserControl to True or the constituent control property will be ignored.
User-drawn controls can examine the DisplayAsDefault property of the AmbientProperties object to determine whether they should draw the extra black border that visually identifies a default button.
If DefaultCancel is True, and the developer makes an instance of your control the default button, the UserControl's AccessKeyPressed event will occur when the user presses the Enter key. The argument of the event will contain the ASCII value 13.
If an instance of your control is the cancel button, the argument of the AccessKeyPress event will contain the ASCII value 27.
Important The status of a default or cancel button can change at any time. You must place code in the UserControl's AmbientChanged event to detect changes in the DisplayAsDefault property, and adjust your control's appearance accordingly.