473,394 Members | 1,852 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,394 software developers and data experts.

Bringing Form to Top/Front

Hi there...hoping somebody can help me out because I am
almost ready to pull out my hair.

My problem is as follows:

In a method in my main form (non MDI app), I instantiate
and .Show another form. As a result of the .Show, the
form's Load event is called and I have a population
routine fires off. Normally, all is well and good and the
new form is active and gets displayed on top of the main
form.

I need to show a messagebox sometimes while populating the
new form, and whenever a messagebox is shown, the new form
always ends up "behind" the old form (but this only
happens when a messagebox is displayed).

After I .Show the form, I've all of the following tried
(not all at once):
newform.BringToFront();
....
newform.Activate();
....
oldform.SendToBack();
....

In addition...I've tried setting the messagebox to be
displayed on the Activated event. I've tried using the
MessageBox owner parameter and passing in the form.

Does anyone have any ideas? Thanks very much for your
help.

Kevin

Nov 15 '05 #1
1 20929
Hi Kevin,
In addition...I've tried setting the messagebox to be
displayed on the Activated event. I've tried using the
MessageBox owner parameter and passing in the form.
This is the right direction to pursue. See the code sample below that
extends this idea and should help solving your problem:

protected override void OnActivated(System.EventArgs e)
{
base.OnActivated(e);

if (!_dataPopulated)
{
// THIS IS IMPORTANT!
this.Activate();

// Immediately prevent calling this code for the second time.
// This should be done before any actual work is done. Looks
// strange but works. You might need to re-name the variable to
// make the code more readable.
_dataPopulated = true;

PopulateData();
}
}

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Kevin Carter" <an*******@discussions.microsoft.com> wrote in message
news:0b****************************@phx.gbl... Hi there...hoping somebody can help me out because I am
almost ready to pull out my hair.

My problem is as follows:

In a method in my main form (non MDI app), I instantiate
and .Show another form. As a result of the .Show, the
form's Load event is called and I have a population
routine fires off. Normally, all is well and good and the
new form is active and gets displayed on top of the main
form.

I need to show a messagebox sometimes while populating the
new form, and whenever a messagebox is shown, the new form
always ends up "behind" the old form (but this only
happens when a messagebox is displayed).

After I .Show the form, I've all of the following tried
(not all at once):
newform.BringToFront();
...
newform.Activate();
...
oldform.SendToBack();
...

In addition...I've tried setting the messagebox to be
displayed on the Activated event. I've tried using the
MessageBox owner parameter and passing in the form.

Does anyone have any ideas? Thanks very much for your
help.

Kevin


Nov 15 '05 #2

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

Similar topics

2
by: Terry | last post by:
when using one form - i can set the z-order. Is there a way programatically to create a "z-order" across .exe. I have 2 .exe - one that paints a background form and then another that fills in...
2
by: Tyson | last post by:
I have got this little piece of code that fires on exit of a text box. It run's my query perfectly based of my form input. But I don't know how to bring result in my query back to a text box on my...
6
by: fumanchu | last post by:
I've got to let end users (really just one person) load billing batch files into a third party app table. They need to specify the billing cycle name, the batch name, and the input file name and...
4
by: Kevin Carter | last post by:
Hi there...hoping somebody can help me out because I am almost ready to pull out my hair. My problem is as follows: In a method in my main form (non MDI app), I instantiate and .Show another...
3
by: Richard L Rosenheim | last post by:
I have the application's form (MainForm) along with a 2nd form (Form2). If the user minimizes MainForm, I also minimize Form2. And when the user restores the application, I also restore Form2. ...
0
by: feng | last post by:
Hi, I am having a strange problem right now and I don't even know how to go about it. Someone please help me! Any inputs will be highly appreciated. We have an application that has a VB.Net...
5
by: Iain Bishop | last post by:
I have a simple form with 4 command buttons and 1 label. The label is sometimes visible and sometimes not. When it is visible I want it to be in front of the buttons. I've tried bringing the label...
1
by: SAL | last post by:
Hello, I'm developing this remoting app (.net 2.0) and I need to bring the server app's form to the front often. Since you can not do cross-thread communication on a form or control without using...
2
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I asked here yesterday about bringing a form to front with hotkey while using different application then mine (meaning, when i'm using outlook, and pressing ALT+T it will bring a form from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.