rautchetan

I have two winforms one is parent form and other will open when user click button which place in parent form.

I want when child form get display,parent form get close.means on that button event i want to close parent form and open child form...

plz help me

Thanks,

Chetan S. Raut.




Re: Windows Forms General multiple c# winforms

Sushil B

Hi Chetan,

Use Application.Run() in Main() of Program file instead of Application.Run(new Form1) as mentioned below:

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Form frmParent = new Form1();

frmParent.Show();

Application.Run();

}

To open the child window by closing the parent window in the button click, use code similar to the following:

private void button1_Click(object sender, EventArgs e)

{

this.Close();

Form2 child = new Form2();

child.Show();

}

When you are ready to exit the application use Application.Exit().

Hope this helps.

- Sushil B






Re: Windows Forms General multiple c# winforms

rautchetan

thanks lot shushil......

i tried it and its working fine....

but new problem occur...

when i m trying to close child form ...i m not able close it...

means i want if somebody close the child form application will stop..

can u help me again

thanks

Chetan S. Raut.






Re: Windows Forms General multiple c# winforms

Sushil B

I am not sure I understood your query correctly...

if you would like to stop the application on the closure of the child form, you can use the following code in the childform_FormClosing() event or other place...

Application.Exit();

Hope I answer your query...

- Sushil






Re: Windows Forms General multiple c# winforms

rautchetan

hay...i tried it out and its working fine for me...

thanks lot for your quick responses......

Regards,

Chetan S. Raut






Re: Windows Forms General multiple c# winforms

Craig Skibo - MSFT

Moving from the Visual Studio Extensibility form to a more appropriate one.




Re: Windows Forms General multiple c# winforms

rautchetan

wht do u mean by that i m not getting....

Chetan S. Raut.