Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling close button VB.NET

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

like image 302
Axe Avatar asked May 30 '11 04:05

Axe


People also ask

How do I turn off Windows close button?

We can hide close button on form by setting this. ControlBox=false; Note that this hides all of those sizing buttons.

What is the purpose of VB net button control?

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.

How do you close a form in VB net?

If you want to close the form then use Me. Close() instead. The Load event will fire again when you create the new instance.


2 Answers

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
like image 181
benblasdell Avatar answered Oct 12 '22 19:10

benblasdell


Set ControlBox property of the form to false

like image 32
Raymund Avatar answered Oct 12 '22 19:10

Raymund