Click here to Skip to main content
15,883,278 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hello, i have problem in vb.net like as below.
i want to disable Close Button[X]of MDI in vb.net.
i don't want to set controlbox property.
otherwise it will not showing icon.
Posted
Updated 30-Jul-22 7:27am

It's in C#, but it's pretty short and should be easy to convert (try DeveloperFusion - they have an online translator):
Disable the Close box on a form[^]
 
Share this answer
 
Comments
Dipak V Nakum 26-Mar-12 6:59am    
i had written in the question i don't want to set controlbox property.
otherwise it will not showing icon that's why any other way to do this.
OriginalGriff 26-Mar-12 7:10am    
Did you read the link, at all? It doesn't set the ControlBox property - or even mention it except to say that it causes problems...
You just need to put this code into your form code behind
VB
Protected Overrides ReadOnly Property CreateParams() As CreateParams
    Get
        Dim param As CreateParams = MyBase.CreateParams
        param.ClassStyle = param.ClassStyle Or &H200
        Return param
    End Get
End Property

and that will disable the (x) close button.
 
Share this answer
 
Hi,
Following is the code-
VB
Private Const CP_NOCLOSE_BUTTON As Integer = &H200
Protected Overloads 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
 
Share this answer
 
Comments
Giorgi Gogiava 18-Dec-13 3:35am    
Its Very usefull

interesting how does it works.
set controlbox property to false
 
Share this answer
 
Comments
CHill60 23-Feb-14 15:19pm    
See Solution 1 from 2 years ago and the OP's question
Use the image button and set the property Onclinetclick=javaScript:window.close(); return false;
 
Share this answer
 
v2
Comments
CHill60 12-Jun-13 7:21am    
If you have additional information for your post use the "Improve question" link, don't post a "solution" to your own question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900