Is there a possible way in VB.NET to disable the close button of the main form as I've seen in many installer! I don't want to hide it, I want to completely disable it!
Thanks in advance
We can hide close button on form by setting this. ControlBox=false; Note that this hides all of those sizing buttons.
Button control is used to perform a click event in Windows Forms, and it can be clicked by a mouse or by pressing Enter keys. It is used to submit all queries of the form by clicking the submit button or transfer control to the next form.
If you want to close the form then use Me. Close() instead. The Load event will fire again when you create the new instance.
Since the blog post in the accepted answer has been taken offline, the following is a solution for C#.NET:
http://www.codeproject.com/Articles/20379/Disabling-Close-Button-on-Forms
Using the C#.NET to VB.NET converter on DeveloperFusion, the equivalent VB.NET solution is:
Private Const CP_NOCLOSE_BUTTON As Integer = &H200
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim myCp As CreateParams = MyBase.CreateParams
myCp.ClassStyle = myCp.ClassStyle Or CP_NOCLOSE_BUTTON
Return myCp
End Get
End Property
Set ControlBox property of the form to false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With