© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
23 replies
willCodeforFood

Issue with Form.Close() in Winforms

I have a custom form called CustomMessageBox

In that form, I have a method that defines a button click, when the button is clicked the form will record the action and close.

I also have a method for CustomMessageBox_Formclosing(), which is called automatically when the form is closed. Now the issue is, within CustomMessageBox_Formclosing(), i have an implementation to handle if the close reason was user induced i.e. the user clicked the X button. But the kicker is that the button method defined earlier, interpretes the close method as a user induced close. How can i resolve this?
image.png
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ WinForms beginner Issue
C#CC# / help
4y ago
Winforms: add an existing form
C#CC# / help
2y ago
✅ UI winforms combobox issue
C#CC# / help
2y ago
❔ How close form-panel
C#CC# / help
3y ago