Link to home
Start Free TrialLog in
Avatar of bmiller250
bmiller250

asked on

Remove Control Box X

Visual Studio .NET 2005   VB.Net 2005  dotNet 2.0

A C# programmer using VB.Net.

We need to remove or disable the X control box on a VB.Net form; you know the one that disposes the form.  We want to keep the minimize and restore down box.
ASKER CERTIFIED SOLUTION
Avatar of xersoft
xersoft

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xersoft
xersoft

Another example with a message asking if the user is sure they want to close.
Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs)
        Dim Response As DialogResult
        Response = MessageBox.Show("Are you sure you want to close?", "Close?", MessageBoxButtons.YesNo)
        If Response <> Windows.Forms.DialogResult.Yes Then
            e.Cancel = True
        End If
 
        MyBase.OnClosing(e)
    End Sub

Open in new window