473,776 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.BringTo Front();
....
newform.Activat e();
....
oldform.SendToB ack();
....

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 20981
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(Sys tem.EventArgs e)
{
base.OnActivate d(e);

if (!_dataPopulate d)
{
// 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*******@disc ussions.microso ft.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.BringTo Front();
...
newform.Activat e();
...
oldform.SendToB ack();
...

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
1589
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 the middle of the screen on top of that form. The .exes need to be separate, although the middle .exe knows about the size of the outer background/border form via a remoted object and events that get triggered on resize. Everything is working...
2
5399
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 form, and shut down query so I can keep using my form again. Thoughts? I am getting a little freaked, I am sure this must be easy? form is; frm_RR_datacapture query is;qprGB_Piece_SizefromTextBox textbox...
6
2806
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 then I can use these values to execute a SQL Server stored procedure to load them into the batch table from the input file (the stored procedure uses Dynamic SQL to Bulk Insert the file to a temp table then processes it into the final table.) My...
4
1715
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 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
3
3234
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. But, Form2 is ending up behind MainForm. Anyone have an idea of how can I set/keep Form2 to be in front of the MainForm? And before someone suggests it, no -- I don't consider TopMost to be the solution. That will make the form the topmost...
0
1609
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 windows form front-end and a middle tier that's also in VB.Net. The two talk to each other via .Net Remoting. If we just run the windows form exe directly, then the application works just
5
25006
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 to the front and sending the buttons to the back. In design view the form looks fine, but whenever I open the form the label is behind the buttons. Has anyone else experienced this and know the solution? Is this a known fault? I wouldn't think...
1
1752
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 Invoke, I declared a delegate to handle the cross-thread call to bring the form forward. Here's my code: Delegate Sub BringMeFront() Public myDelBringFormFront As BringMeFront
2
4071
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 my application to front), my problem was that after i press the hotkey, the window stays in minimize state instead of being in the front. i fount an article in google explaining (i think) how to solve this problem, but i couldn't understand what...
0
9628
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9464
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10061
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8954
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5368
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4031
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
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.