Close down
-
Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.
-
Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.
hi twsted f8 to Remove the button to Maximise, Right Click on your Form and click on Properties, in your Properties Window, look for Window Style --> You will find the Option "ControlBox", set it to "False" and you Buttons will be gone. but Now if you set the Controlbox to false then you will not see the (X) button to close your Form, you will just have to create your own button. you can but the same code in the Following events The Following code is in your Form closing event
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If MessageBox.Show("Do you want to Exit", "Question", MessageBoxButtons.YesNo) = DialogResult.Yes Then Me.Dispose() Else '''Do nothing End If End Sub
Note that you can Create a button for your self and write the same code. Hope this helps Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za -
Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.
twsted f8 wrote:
I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called?
look at the formborderstyle property there are several wich will do what you want all with different looks
twsted f8 wrote:
I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property?
events: formclosing formclosed whith e.CloseReason=CloseReason.UserClosing you can distinguish between a user closing you'r form or another programme (or you'r own programme) hope this helps
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.
-
hi twsted f8 to Remove the button to Maximise, Right Click on your Form and click on Properties, in your Properties Window, look for Window Style --> You will find the Option "ControlBox", set it to "False" and you Buttons will be gone. but Now if you set the Controlbox to false then you will not see the (X) button to close your Form, you will just have to create your own button. you can but the same code in the Following events The Following code is in your Form closing event
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If MessageBox.Show("Do you want to Exit", "Question", MessageBoxButtons.YesNo) = DialogResult.Yes Then Me.Dispose() Else '''Do nothing End If End Sub
Note that you can Create a button for your self and write the same code. Hope this helps Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.zaVuyiswamb wrote:
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If MessageBox.Show("Do you want to Exit", "Question", MessageBoxButtons.YesNo) = DialogResult.Yes Then Me.Dispose() Else '''Do nothing End If End Sub
now in both cases the form will close instead of '''do nothing there should be e.cancel = true
Vuyiswamb wrote:
to Remove the button to Maximise, Right Click on your Form and click on Properties, in your Properties Window, look for Window Style --> You will find the Option "ControlBox", set it to "False" and you Buttons will be gone
the user is still able to maximise his window by dubbleclicking the title bar using the formborderstyle property might be a better way to accomplish what he wants
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.
-
Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.
Just an idea - why not allow the users to maximize the form and anchor objects on the form. This will then rescale the form as the user resizes it. I mention this just in case you have not yet figured out how to allow the form to rescale - and in case that is what you were trying to prevent. Apologies if I am teaching my grandmother to suck eggs here... Regards Guy
You always pass failure on the way to success.
-
twsted f8 wrote:
I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called?
look at the formborderstyle property there are several wich will do what you want all with different looks
twsted f8 wrote:
I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property?
events: formclosing formclosed whith e.CloseReason=CloseReason.UserClosing you can distinguish between a user closing you'r form or another programme (or you'r own programme) hope this helps
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.
the best i found to let my form remain in maximized state is by overriding onSizeChanged method (or by handling sizechanged event) and writing following lines there If Not DesignMode Then If Not Me.WindowState = FormWindowState.Maximized Then Me.WindowState = FormWindowState.Maximized End If End If if user tries to change the size even by clicking on maximize button the form will restore back to previous stat. keep in mind initially you will have to set the windowstate of form to Maximized
Salman Sheikh
-
the best i found to let my form remain in maximized state is by overriding onSizeChanged method (or by handling sizechanged event) and writing following lines there If Not DesignMode Then If Not Me.WindowState = FormWindowState.Maximized Then Me.WindowState = FormWindowState.Maximized End If End If if user tries to change the size even by clicking on maximize button the form will restore back to previous stat. keep in mind initially you will have to set the windowstate of form to Maximized
Salman Sheikh
true this will work nice if you want the form to be maximised but the OP asked to prevent maximising so I figured the form isn't maximised at all (also not at start). you can still use you're code to accomplish this (just put the size back to original size) but the user will get the arrows for resising the window, will be able to click and drag, might even be able to resize the window for a split second. All of this will result in a very confused user and a flickering screen so... but if you want the windowstate to be maximised at all times you'r code would work, although I think the window will flicker for a split second (not shure about this)
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.
-
Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.
i think we have a property called Cancel in the event of form_close so you have to do this to prevent closing window
e.cancel=true
A.E.K