how can i control the "X" button
on the upper right of the Form??
Note: Upper Right of the form...
plsss help me
Printable View
how can i control the "X" button
on the upper right of the Form??
Note: Upper Right of the form...
plsss help me
What do you mean by "control". CHeck out the post titled:
Can I stop a form closing when the Close button is clicked?
yes that's what i mean...
is there such code that control
the "X" button???
Post titled'
"How to stop closing form?"
Use the FormClosing and/or the FormClosed events to do what's neededQuote:
Originally Posted by ken_coffee
Not such a good idea. There's no way to specifically distinguish between the user clicking the Close box (as it's officially named) and your code calling Me.Close.Quote:
Originally Posted by JuggaloBrotha
Prevention is better than cure. If you don't want the user to use the Close box then it's best to disable it. There's a link in my signature that demonstrates how to do that.
Well no but its very easy to implement something to check that... just a simple boolean value that you set to True when you do want the program to close works fine for me.Quote:
Originally Posted by jmcilhinney
Also there's the CloseReason property that is passed to the FormClosing event through the e argument that lets you determine whether the user is closing the form or if windows is shutting down the form etc.
example:
I do agree that most of the time prevention is better than the cure but to me disabling the X makes the program look unprofessional as you very rarely see a decent peice of software that does that... so its better for me to just make a warning message appear or something when the user clicks the X. I guess its just a personal preference though?Code:Public Class Form1
Dim letmeclose As Boolean = False
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If letmeclose = False Then
e.Cancel = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
letmeclose = True
Me.Close()
End Sub
End Class
All true but, regardless of any of that, prevention is better than cure. If the user can't use the Close box then it really is preferable to disable it. It's pretty annoying as a user to have something presented to you as though you can use it and then have a message pop up and say that you can't. Worse still, if you don't display a message then the user may think your app is broken because a standard piece of Windows functionality is present but doesn't do what it's supposed to do.Quote:
Originally Posted by chris128
i got your points
^_^
tnx alot
u give me a real
point of view on
what shoud i do and not to do
thx alot buddies
^_^
more support for a newbie ^_^
ty