Solved

C# Form does not come to front.

Posted on 2004-09-22
5
938 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dictionary and array of [N] size - performance tuned 12 52
c#, case, if 4 37
Inserting LocalDB Table to SQL Server C# 3 51
Fastest way to get file count in MS Server 2012 3 36
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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