Disable the Control Box

J

John Wright

Is there a setting on the form I can set to hide or disable the close button
(The Red "X" in the top right of an XP form) so the users cannot exit the
program, but still show the min and max buttons. The problem I have is on
some of the tabs in my program I have validation events on textboxes. When
the users clicks the "X" to close the program, the validation event fires
before exiting the program causing some confusion. Thanks.

John
 
K

Kerry Moorman

John,

If you don't want the validation events to prevent the form from closing
then in the form's FormClosing event use:

e.Cancel = False

Kerry Moorman
 
K

kimiraikkonen

Is there a setting on the form I can set to hide or disable the close button
(The Red "X" in the top right of an XP form) so the users cannot exit the
program, but still show the min and max buttons. The problem I have is on
some of the tabs in my program I have validation events on textboxes. When
the users clicks the "X" to close the program, the validation event fires
before exiting the program causing some confusion. Thanks.

John

If i recall correctly this has been discussed before, you need to use
that code in your form:

' ----Begin----

Public Class Form1

Private Const CP_NOCLOSE_BUTTON As Integer = 512

Protected Overrides ReadOnly Property CreateParams() As
System.Windows.Forms.CreateParams
Get
Dim noclose As CreateParams
noclose = MyBase.CreateParams
noclose.ClassStyle = CP_NOCLOSE_BUTTON
Return noclose
End Get
End Property

' Codes...

End Class

' ----End-----

Hope this helps,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top