473,574 Members | 3,125 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display second form?

My application start like this:

frmMaster MainForm = new frmMaster();
System.Windows. Forms.Applicati on.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.Applicati on.Run(SecondFo rm);
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 16372
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.BeginIn voke

--
HTH
Stoitcho Goutsev (100)

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

frmMaster MainForm = new frmMaster();
System.Windows. Forms.Applicati on.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.Applicati on.Run(SecondFo rm);
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
4249
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 second form when it is called. Both forms are .htm files that call themselves when the submit button is press via the following command in each form:...
5
5095
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 OrderTest2. The first block of code below is the first form. This form calls itself and does perform the validations correctly as I want. However,...
2
5038
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 continues to process message loops. At the moment, my second form contains this code (and more irrelevant code not listed) public class...
3
1524
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 at the second form at some point I use a second form Form f = new FormX(); f.ShowDialog();
0
1358
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 sub form. In main form's loading event( and doubleclick event of notifyicon ), i wrote something like: notifyIcon.Visible = false;
2
3199
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 attached to the On Open event. However, right after the msg box pops saying"no records", this is followed by another msg box with "TheOpen Form...
2
1318
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 file. This all works great the second form is presented with the information. The problem that I have is the second form is supposed to allow a user...
4
3017
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 added a MustOverride Sub and have added MustInherit to the class definition. I then created a second form, this time by adding a class module, and...
0
1083
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 changed, I want to display this new value in a textbox on the second form (Form#2). I have listed what I believe to be the significant parts of the code...
0
8052
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8234
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7815
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8098
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6452
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5620
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5300
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3749
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2243
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 we have to send another system

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.