|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Q: Closing a formHi
How can I tell if a form has been closed using the red cross in the top right of the form rather than, for example, pressing an OK button? Geoff > How can I tell if a form has been closed using the red cross in the You could have a form level variable called OkClicked. In the btnOk.Clicked > top right of the form rather than, for example, pressing an OK button? event handler, set OkClicked = True. Now in your FormClosing event handler check your OkClicked variable and handle it accordingly. Typcially, this is used to disallow a user to close the form witht the X and require them to use Ok. Incidentally, the FormClosingEventArgs includes a property for ClosingReason. There doesn't appear to be an option to determine between closed by X or closed by form.close and reports both as UserClosing. Below is some sample code: Private OkClicked As Boolean Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click OkClicked = True Me.Close() End Sub Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If Not OkClicked Then e.Cancel = True End Sub Jim Wooley
Text on Image Resolution
Reading Stream After RedirectStandardOutput=True Blocks I can't find the error here.... Serial Date Stored procedure handling 1 parent record and multiple child recor Confusion on Protected Overrides Loop through columns of all datarows in a dataset my form cannot from from network checking for EOF DataGridView validation to underlying DataSource |
|||||||||||||||||||||||