2

my problem is so simple but I can't seem to get it solved.

I just want to remove the Close Button from my form and don't remove the icon.

I used ControlBox = false but it removes the form's icon as well, I just want to keep it.

Is there anyway I can do it either by code or properties?

Crono
  • 10,211
  • 6
  • 43
  • 75
White8Tiger
  • 294
  • 4
  • 19

2 Answers2

1

Add it under Public Class Form ... :

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

It should work perfectly!

Kashish Arora
  • 900
  • 5
  • 25
  • 39
0

If you want something full of capabilities, then you could use my SystemMenuManager By Elektro Class.

Just add all the code into a single Class and use it like in the example below:

Public Class Form1

    Dim SystemMenu As New SystemMenuManager(Me)

    Private Shadows Sub Load() Handles MyBase.Load

        ' Disables the 'Close' button and 'Close' menu-item.
        SystemMenu.SetItemState(SystemMenuManager.Item.Close, 
                                SystemMenuManager.ItemState.Disabled)

    End Sub

End Class
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417