How can I prevent an user to close the form clicking on the (X) button
Thnx!
Kapalic
Windows Forms General
My first question is why don't you want the user to close the form From a UI perspective the behavior should be the same as clicking a Cancel button and it's best to code your application where both events use the same code. But, you may have a form that you don't want the user to cancel or at least not cancel right away.
Setting the ControlBox property to False is one way to do this. Since you don't want to user to have this ability, just don't make it visible. You can also toggle this property setting at runtime (unlike in VB6). If you want to disable the button instead, this thread explains how to do it in VB.Net
Hi,kapalic
Here is the code to prevent closing form.
Private Sub FormClosing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
e.Cancel = True
I want user only close the form with my given button. How can I detect that cross button was pressed Please show me an example.
Thnx!
Kapalic