close window

This is a discussion on close window within the C# Programming forums, part of the General Programming Boards category; hi, i want to keep main form when clicking close button (form closing event). so it has to close after ...

  1. #1
    sgh
    sgh is offline
    Registered User
    Join Date
    Apr 2008
    Posts
    58

    close window

    hi,
    i want to keep main form when clicking close button (form closing event).
    so it has to close after process some condition statement.
    here are some code.

    Code:
    private void MainFrm_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (active_flag && checkLogin())
                    this.Close();
                else
                    //keep form
            }
    how can i fix it?
    regards

  2. #2
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    Use the e.Cancel boolean.

    Code:
    if (we don't want to allow the window to close)
        e.Cancel = true;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 04:07 PM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  3. my wndProc is out of scope
    By Raison in forum Windows Programming
    Replies: 35
    Last Post: 06-25-2004, 08:23 AM
  4. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 06:38 PM
  5. Invoking MSWord
    By Donn in forum C Programming
    Replies: 21
    Last Post: 09-08-2001, 05:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21