Solved

C# Form does not come to front.

Posted on 2004-09-22
5
933 Views
Last Modified: 2008-02-26
I am writing a test messenger that runs minimized until a message comes in.  At that time, the form needs to show itself.  I am currently using the Show() method.  It works unless you are using word, excel, etc.  At that time, it shows itself but it is behind the word, excel, etc sheet.  How can I make it come to the front so it is the top level form?  Here is the brief code

Show();
WindowState = FormWindowState.Normal;                  

Thank you in advance,

Dean
0
Comment
Question by:CDFA_Inc
5 Comments
 
LVL 10

Accepted Solution

by:
eternal_21 earned 125 total points
ID: 12127859
You could use:

  ShowDialog();

or

  Show()
  TopMost = true;
0
 

Author Comment

by:CDFA_Inc
ID: 12127949
I tried that it doesn't show up in front of the application you are using.
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 12128872
If you set the TopMost property to true, it certainly should show up on top of Excel (or any office applications).  Could you post some more of your code?  Is the form minimized already, or is it a 'new' form that you are displaying?
0
 
LVL 3

Expert Comment

by:chintan_vaishya
ID: 12130253
HI CDFA,

Try using BringToFront property of the Form.

Form.BringToFront();

Hope this helps you.
Good Luck.
Chintan.
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 12130939
Call the Activate() method of the form after you call the Show() method. This will just blink the form and will not bring it to the front, which is (I think) a better behaviour for a messenger because it will not interupt the user who, for example, is writing a letter in Word at that moment.

Here is what is written about the Activate() method:
Activating a form brings it to the front if this is the active application, or it flashes the window caption if this is not the active application. The form must be visible for this method to have any effect.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now