The setters from the CLR source for System.Windows.Forms.Form.AcceptButton
and System.Windows.Forms.Form.CancelButton
are below.
Note that the CancelButton
setter sets the DialogResult
property of the specified button, while the AcceptButton
setter doesn't.
At first review this seems to be a bug in the WinForms source code.
Code:
Public Sub set_AcceptButton(ByVal value As IButtonControl)
If (Not Me.AcceptButton Is value) Then
MyBase.Properties.SetObject(Form.PropAcceptButton, value)
Me.UpdateDefaultButton
End If
End Sub
Public Sub set_CancelButton(ByVal value As IButtonControl)
MyBase.Properties.SetObject(Form.PropCancelButton, value)
If ((Not value Is Nothing) AndAlso (value.DialogResult = DialogResult.None)) Then
value.DialogResult = DialogResult.Cancel
End If
End Sub