Results 1 to 3 of 3

Thread: [RESOLVED] disable 'close' button of windows form

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    37

    Resolved [RESOLVED] disable 'close' button of windows form

    my form i need to disable to function to close the application, anyone knows how do i make it do nothing or disable the close button of the form?

  2. #2
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: disable 'close' button of windows form

    You can remote the 'Control Box' (Minimize, Resize and Close) with

    Me.ControlBox = False

    You can also check with the user to ensure they really want to close your application with something like the following

    VB Code:
    1. Private Sub FormClosing(ByVal sender AS object, _
    2.     ByVal e as System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    3.    If MessageBox.Show("Are you sure you wish to close") = DialogResult.Yes Then
    4.       If MessageBox.Show("Are you really sure :P ") = DialogResult.Yes Then
    5.         Me.Close()
    6.       End IF
    7.    End If
    8. End Sub

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: disable 'close' button of windows form

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width