Your approach is kind of confusing. It seems that you need to use your
ChildForm as DialogBox but on other hand you are saying that multiple
ChildForms can be open at a time. Anyway for your requirement #2, i.e.
when "Exit" button on ChildForm is clicked switch back to MainForm,
you can register a handler for Form_Closed event of ChildForm, in your
MainForm, then whenever ChildForm is closed this handler will be
executed in MainForm there you can call the Focusing methods to
activate the MainForm. E.g.,
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ChildForm frmNew;
frmNew = new ChildForm();
frmNew.FormClosed += new
FormClosedEventHandler(childform_closed);
frmNew.Show();
}
private void childform_closed(object sender,
FormClosedEventArgs e)
{
this.Focus();
this.Activate();
}
}
Regards,
Arsalan Tamiz
On Sep 8, 8:18 pm, Raven <[EMAIL PROTECTED]> wrote:
> hello,
>
> I am using VS2005(C#) and new to windows forms programming and
> couldn't find a solution for switching back and forth between multiple
> forms.I have 2 forms (MainForm and ChildForm) and 4 buttons on the
> main form each calling ChildForm with different parameters and an exit
> button.So if possible I want to achieve 2 things..
>
> 1) With ChildForm open, I want to switch back to main from and
> exit.But i couldn't find how i can do this without first closing the
> child form.
>
> 2) More importantly i want to open multiple instances of ChildForm
> (Push button 1 create ChildForm A, switch back MainForm push button 2
> create ChildForm B) but i am unable to access MainForm without closing
> ChildForm again.
>
> Maybe i should treat forms independent of each other but i dont know
> how(For example create Form1 push the button and create Form2 and
> exiting form1 doesn't exit form2.and application only exits if all
> forms are closed)
>
> Thank you very much in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---