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?
15 Replies
What I have tried : Setting the form's .Visiblle to false, which works in theory, but i dont want to leave many forms open like that
I am not sure I understood your needs but how about this
basically when button is clicked u set a flag to true
and then it will check both the flag and the reason
if they match it closes otherwise it ignores
you can also hide the close button
Will try this
is that what u want to do?
Not really but im open to trying a new approach
what is your goal?
because from what u said u want to know if the click came from the button vs the X
Yes exactly
I managed to find a solution, I used a slight modification to what you described.
Thank you
yeah I mean the idea is simple just using a bool to identify where it came from since its only 2 locations
Use the /close command to mark a forum thread as answered
can anyone use this when its done, or is this just for admins?
its only for who created the thread and mods+
but the bot sending the message anyone can do its just
$close
so someone pasting a powershell script without code blocks could really fuck the bot over
try and find out
$close = "$close"
Use the /close command to mark a forum thread as answered