473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Using multiple windows forms

Hi,

I am trying to create an application with multiple windows forms. The
problem that I have is that after creating the window forms, I do not
know how to open formN after closing Main form. Each form is in its
own class. What I want to do is the following:

1. Click a button on Main menu.
2. Close main menu ( I would use hide if possible)
3. Open form2
4. Open other forms and hide or close the previous form.
5. Eventually able to go back to Main form.

I have been experimenting with creating new forms from Main form and
closing/disposing them. However, I would like to learn how to use
forms that I can create using the windows forms that I have created.
Any help is appreciated. Thanks.
Mario

May 19 '06 #1
2 4877
Mario wrote:
Hi,

I am trying to create an application with multiple windows forms. The
problem that I have is that after creating the window forms, I do not
know how to open formN after closing Main form. Each form is in its
own class. What I want to do is the following:

1. Click a button on Main menu.
2. Close main menu ( I would use hide if possible)
3. Open form2
4. Open other forms and hide or close the previous form.
5. Eventually able to go back to Main form.

I have been experimenting with creating new forms from Main form and
closing/disposing them. However, I would like to learn how to use
forms that I can create using the windows forms that I have created.
Any help is appreciated. Thanks.
Mario

You need to subscribe to the FormClosing or FormClosed event of your
child on your main form or set a delegate on your child forms which gets
invoked in the closing method of your child forms.
main form:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void cmdChild_Click(object sender, EventArgs e)
{
frmChild Child = new frmChild();
Child.FormClosed += new FormClosedEventHandler(Child_FormClosed);
Child.Show();
this.Hide();
}

void Child_FormClosed(object sender, FormClosedEventArgs e)
{
this.Show();
}

private void cmdChildDelegate_Click(object sender, EventArgs e)
{
frmChildDelegate Del = new frmChildDelegate(new
MethodInvoker(delegate { this.Show(); }));
Del.Show();
this.Hide();
}
}

Delegate child Form:
public partial class frmChildDelegate : Form
{

MethodInvoker ShowParent;

public frmChildDelegate(MethodInvoker showParent)
{
ShowParent = showParent;
InitializeComponent();
}

private void frmChildDelegate_FormClosing(object sender,
FormClosingEventArgs e)
{
ShowParent();
}
}
May 19 '06 #2
Hi John,

Thanks for the reply. I will try your advice and keep you posted.
Thanks.

Mario

May 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
1
by: Alasdair | last post by:
Friends, I'm an old C programmer who upgraded to C++ but was never comfortable with it. I've recently moved to C# and love it but I obviously am missing some of the subtleties. I thought the...
6
by: Chuck Bowling | last post by:
C# newbie warning... It'll probably be easier to explain what i want in code: ------- abstract class Base { ... }
2
by: John Granade | last post by:
I'm looking for the best way to make a dataset available from multiple Windows forms. The dataset is created from an XML file. I have a main form (frmMain) that loads the dataset and reads the...
0
by: Becker | last post by:
I have a datatable that I use to display running processes. These running processes are spawned as different threads. I use the readerwriterlock class to ensure that when I write to the datatable,...
2
by: Carl Gilbert | last post by:
Hi I have a math kinda problem where I'm trying to split some lines when two or more lines connect two shapes. The reason I am doing this is to make it clear that there are multiple lines...
22
by: Brett Romero | last post by:
If my UI app uses three DLLs and two of those DLLs reference something named utilities.dll, does the UI app load utilities.dll twice or does the compiler recognize what is going on and load...
6
by: Alec MacLean | last post by:
Hi, I've created a small application for our company extranet (staff bulletins) that outputs a list of links to PDF's that are stored in a SQL table. The user clicks a link and the PDF is...
0
by: vimalkanth | last post by:
Hi, We have a Delphi 5 Windows application which is built as a Client- Designer-Server application with http-based data exchange between Client/Designer and Server. Client application is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.