Results 1 to 5 of 5

Thread: How can i hide my second form dialog without bliking form not closing my first form?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2011
    Posts
    137

    Question How can i hide my second form dialog without bliking form not closing my first form?

    Sorry guys the title shoud be this

    How can i close form1 with button exit to show form2 without bliking form - After i click close program it shoud close form2 and show again form1 as normal form with position ?

    I am using Visual studio 2013. I created two forms, form1 with a button to open form2 and the form2 has a button "exit" which will take me back to form1

    This is my code i have for so far.

    Code:
    Form2.StartPosition = Windows.Forms.FormStartPosition.Manual
    Form2.Bounds = Me.Bounds
    Form2.ShowDialog()
    button exit close form1 and show form2 - After i want to close form2 it shoud close form2 and show form1 again as normal form.






    Thanks in advance guys
    Last edited by polas; Mar 27th, 2014 at 03:44 AM.

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

    Re: How can i hide my second form dialog without bliking form not closing my first fo

    Um, no, closing Form2 is not going to close Form1. Form1 will only close if you close it, which that code does not do. If you want to hide Form1 before showing Form2 then call Form1's Hide method. If you want show Form1 again after Form2 closes then call Form1's Show method.
    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

  3. #3
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Re: How can i hide my second form dialog without bliking form not closing my first fo

    what about

    Code:
    Form2.Show()
    Form1.Hide()

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2011
    Posts
    137

    Re: How can i hide my second form dialog without bliking form not closing my first fo

    You didn't understand what i want.
    I do not wanna hide it i just wanna close form like in other programs.
    When i click x button to close form2 it should close not all forms but only form2 and back to form1 as it was.

    How to do that ?
    I know that it is really possible and i know that my code just set position after i open form2 it's ok but i need code to not hide but close form not all program.

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: How can i hide my second form dialog without bliking form not closing my first fo

    Change the Application Shutdown Mode to 'When last form closes'. Then after showing form2 you can close form1.

    If you want from2 to show form1 when it closes then show form1 in form2's FormClosing event handler.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Tags for this Thread

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