473,486 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to display second form?

My application start like this:

frmMaster MainForm = new frmMaster();
System.Windows.Forms.Application.Run(MainForm);

The flow is that MainForm shows then a SecondForm shows after the user
does something. This is an MDI app so SecondForm needs to always be
inside MainForm. There are times I need to automatically load the app
and display second form. I'm not sure how that is done. If I do:

frmMaster MainForm = new frmMaster();
frmSecond SecondForm = new frmSecond (someobject);
System.Windows.Forms.Application.Run(SecondForm);
MainForm.Show();
SecondForm.Show();

MainForm is never displayed and SecondForm loads by itself. No
processing needs to take place on MainForm when SecondForm loads
automatically, as in the above code. How can I get SecondForm loaded
inside the MainForm MDI?

Thanks,
Brett

Jan 26 '06 #1
3 16363
Brett,

Just move creating and showing the second form in the first form constructor
or as a response to the Load event. .NET 2.0's forms also has one very
usefull event - "Shown" that fould be a good place for that. BTW Shown can
be easily implemented in .NET 1.x using Control.BeginInvoke

--
HTH
Stoitcho Goutsev (100)

"Brett Romero" <ac*****@cygen.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
My application start like this:

frmMaster MainForm = new frmMaster();
System.Windows.Forms.Application.Run(MainForm);

The flow is that MainForm shows then a SecondForm shows after the user
does something. This is an MDI app so SecondForm needs to always be
inside MainForm. There are times I need to automatically load the app
and display second form. I'm not sure how that is done. If I do:

frmMaster MainForm = new frmMaster();
frmSecond SecondForm = new frmSecond (someobject);
System.Windows.Forms.Application.Run(SecondForm);
MainForm.Show();
SecondForm.Show();

MainForm is never displayed and SecondForm loads by itself. No
processing needs to take place on MainForm when SecondForm loads
automatically, as in the above code. How can I get SecondForm loaded
inside the MainForm MDI?

Thanks,
Brett

Jan 26 '06 #2
Got it! Thanks.

I'm doing this in first form's constructor:

frmSecondForm secondForm = new frmSecondForm (someobject);
secondForm .Show();
secondForm .BringToFront();

but the second form always ends up behind the first. I even put
BringToFront() in the second form's constructor. I tried focus() as
well. No dice.

Any ideas how I can get the second form to the front?

Thanks,
Brett

Jan 26 '06 #3
Sorry. These are MDI forms. So:

frmSecondForm secondForm = new frmSecondForm (someobject);
secondForm .MdiParent = this;
secondForm .Show();

which works.

Brett

Jan 26 '06 #4

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

Similar topics

5
4244
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the...
5
5084
by: TG | last post by:
Conditions: Register globals is set to on. Parse html as php is set to on. I have two forms OrderTest1 and OrderTest2 and need to be able to validate the data from OrderTest1 before passing to...
2
5031
by: bryhhh | last post by:
I have am still learning C#, so please bear with me. I have an application that needs to open a second form, but I need the second form to process message loops, whilst the original form also...
3
1521
by: MajorTom | last post by:
Hello everybody, I need help on how to use the same datase in two different form, this is the scenario: at the first form I load a big dataset (ds1) for short, but I not want to load it again...
0
1351
by: yasker | last post by:
Hi, I got a problem in display a sub form. My app contains two form: main and sub. I want sub form display before main form, to provide some information to it. I use a NotifyIcon to activity...
2
3182
by: kev | last post by:
Hi Folks, I have created a search query in which it successfully returns correct results. When there are no records returned, instead of giving out a blank form i created a pop-up msg which is...
2
1313
by: slb813 | last post by:
Hello, I am new to PHP and have created a file that will show a HTML page to ank for a record key, then select the kay from a MS Access database and display it on another form in the same PHP...
4
3011
by: Phil | last post by:
VS 2008 I have a windows form that was created in the normal way using the form designer. I do not wish to use this form directly though, I want to use it as a basis for some other forms. I have...
0
1080
by: Terje | last post by:
The application has two forms. The main form (Form#1) utilizes threading. One of these threads is used for reading in parameters from a TCP/IP socket. Once the value of one specific parameter has...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.