{"id":9397,"date":"2015-06-29T08:00:25","date_gmt":"2015-06-29T15:00:25","guid":{"rendered":"https:\/\/www.sapien.com\/blog\/?p=9397"},"modified":"2015-12-23T11:05:58","modified_gmt":"2015-12-23T19:05:58","slug":"why-does-this-button-close-my-form","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2015\/06\/29\/why-does-this-button-close-my-form\/","title":{"rendered":"Why does this button close my form?"},"content":{"rendered":"<p>Have you ever copied a button and found that when a user presses it, the form closes immediately afterwards? We are here to answer:<\/p>\n<p><strong>Why does this button close my form?<\/strong><\/p>\n<p>The reason the form closes is that the Button control\u2019s <em>DialogResult<\/em> property is set to a value other than <em>None<\/em>. 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\u2019s click event script block.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/06\/image7.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/06\/image_thumb7.png\" alt=\"image\" width=\"244\" height=\"182\" border=\"0\" \/><\/a><\/p>\n<p>So next time you copy an OK or Cancel button, be sure to set the button\u2019s <em>DialogResult<\/em> to <em>None.<\/em><\/p>\n<p>For more information, see:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.sapien.com\/blog\/2015\/12\/23\/how-i-learned-to-love-dialogresult\/\" target=\"_blank\">How I learned to love DialogResult<\/a><\/li>\n<li><a href=\"https:\/\/www.sapien.com\/blog\/2011\/06\/07\/primalforms-2011-spotlight-on-the-button-control\/\" target=\"_blank\">Spotlight on the Button Control<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019s DialogResult property is set to a value other than None. This property tells the [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[703,303,25],"tags":[652,665,28,1016,312],"class_list":["post-9397","post","type-post","status-publish","format-standard","hentry","category-powershell-studio","category-tip","category-windows-powershell","tag-button","tag-form","tag-powershell","tag-powershell-studio","tag-winforms"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/9397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=9397"}],"version-history":[{"count":6,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/9397\/revisions"}],"predecessor-version":[{"id":10930,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/9397\/revisions\/10930"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=9397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=9397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=9397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}