rustyfancy Posted March 24, 2004 Posted March 24, 2004 Does anyone know how to override or disable the Exit button ("X") on the top right hand corner of a windows form?? The maximize and minimize controls can be disable though the property builder, but the Exit button cannot. I'm working with multiple forms, and by default when the "X" button is clicked, the form is disposed, and thus, lost forever!!!!!!! ---Matt Quote
Celeron Posted March 24, 2004 Posted March 24, 2004 Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing e.Cancel = True End Sub This will not allow you to close the form at all, unless you use the End keyword or create a special function that is called from Form1_Closing. Quote
techmanbd Posted March 24, 2004 Posted March 24, 2004 If you are disabling the min and max as well and don't want them to have the ability to hit the x button you can set the "controlbox" to false in the properties and you won't see those at all Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Rick_Fla Posted March 25, 2004 Posted March 25, 2004 Something I have used is using the example by Celeron and a form level variable called mblnFromExitButton Private Sub frmLapTimes_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If mblnFromExitButton = False Then e.Cancel = True End If End Sub Then in your exit button, just set the mblnFromExitButton to true. Quote "Nobody knows what I do until I stop doing it."
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.