CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: [RESOLVED] Forms and Close() method

  1. #1
    Join Date
    Dec 2007
    Posts
    12

    [RESOLVED] Forms and Close() method

    Hi all!!

    I am developing a Windows based application using VS 2005.
    I have a main form with a main menu on it and I use the menu items to call other forms of the application. When one of the menu items is clicked a form (which I call Form1) is called using the ShowDialog method. Then on this form there is a button that when clicked calls another form using ShowDialog again (called Form2). Form2 has a button that when clicked I call the Close() method to close the form. This way Form2 is closed but at the same time Form1 is closed too and I can not understand why. And I don't want this to happen. After displaying some info on Form2 I want to continue using Form1.

    Any idea?? Please help ASAP....

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: Forms and Close() method

    I was unable to reproduce the described behaviour. Maybe you could post a small project showing the problem?

    - petter

  3. #3
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    Re: Forms and Close() method

    I cannot see why this would happen but...

    One thing, rather than calling Form.Close() would be to assign the Forms 'CancelButton' property (in the designer) to the [Close] button and see if this cures your problem.
    Rob
    -
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Forms and Close() method

    Show us the code. You are doing something to cause it, but we can't know what that is.

  5. #5
    Join Date
    Nov 2008
    Location
    United States
    Posts
    81

    Re: Forms and Close() method

    Quote Originally Posted by BigEd781 View Post
    Show us the code.
    Show me the money!!!

    Heh, yep, it's not possible to do this unless you have a mistake in your coding. Close() does not effect Owners.
    Three5Eight
    Using: MS C# 08 EE, MS SQL 05 EE, C++ .Net 08 EE, Vista Home Premium, XP Home

  6. #6
    Join Date
    Dec 2007
    Posts
    12

    Re: Forms and Close() method

    Thank you all for your time!!

    I couldn't figure out what the problem was but after I tried some different things, I deleted the button that called Form2 on Form1 and recreated it and no problem remained))

    Thank you again!

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)