Have you ever copied a button and found that when a user presses it, the form closes immediately afterwards? We are here to answer:
Why does this button close my form?
The reason the form closes is that the Button control’s DialogResult property is set to a value other than None. This property tells the form to close after the user has clicked the button without you having to explicitly close the form in the button’s click event script block.
So next time you copy an OK or Cancel button, be sure to set the button’s DialogResult to None.
For more information, see:
Why does this button close my form? http://t.co/yg0FsZWuAr #Sapien
New stuff from the SAPIEN blog: Why does this button close my form? http://t.co/d6nPZcuYfU
DialogResult property of buttons is evil! Unless its value is None, it ignores the event handler & closes the form. https://t.co/UNInFygxIL
Experience GUI programmers probably disagree, but I always set DialogResult=None & write explicit code for buttons.
https://t.co/UNInFygxIL
#PowerShellStudio, “Dialog Style Template” OK button has DialogResult=OK. It closes the form, ignores event code. https://t.co/UNInFygxIL
RT @juneb_get_help: #PowerShellStudio, “Dialog Style Template” OK button has DialogResult=OK. It closes the form, ignores event code. https…
Why does this button close my form? https://t.co/d8lXTFCH5w
Why does this button close my form? https://t.co/05mDh4sHIy via @SAPIENTech