Visually remove/disable close button from title bar .NET

前端 未结 13 944
后悔当初
后悔当初 2020-12-03 21:51

I have been asked to remove or disable the close button from our VB .NET 2005 MDI application. There are no native properties on a form that allow you to grey out the close

相关标签:
13条回答
  • 2020-12-03 22:35

    Prevent to close the form, but hide it:

    Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Me.WindowState = FormWindowState.Minimized 
        Me.Visible=false
        e.Cancel = True
    End Sub
    
    0 讨论(0)
  • 2020-12-03 22:36

    When you press the X box on the form. The Form1_Closing is done first, then the Form1_Closed is done.

    The e.Cancel = True in the Form1_Closing - prevents Form1_Closed from being called therefore, leaving your form still active.

    0 讨论(0)
  • 2020-12-03 22:37

    Making a Form without a Titlebar in Visual Basic.

    Go to Form Properties and set both ControlBox and ShowIcon to false.

    Then, clear all the text from the form's text property.

    0 讨论(0)
  • 2020-12-03 22:40

    Select (or click) the form itself Click on events in the property window (the little lightning bolt icon). Look for Form.Closing and double click it. Then type: e.cancel=true

    0 讨论(0)
  • 2020-12-03 22:43

    Just select the required form and in the properties section, set controlBox = false That just worked for me :)

    0 讨论(0)
  • 2020-12-03 22:44

    You can set the ControlBox property to False, but the whole title bar will be gone but the title itself...

    0 讨论(0)
提交回复
热议问题