• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

bring a WinForm into focus

How do you bring a WinForm into focus?

i.e. have multiple WinForms opened -- want to be able to instruct a WinForm to come forward (on top) so that WinForm's content can be viewed.
1 Solution
What kind of application do you have ?
A single or multiple document interface ?

Focus Form
amillyardAuthor Commented:
code snippet is how I create and initially show the window.

obviously, other windows can be opened at any time and/or the user minimise windows -- want to be able to programmically make a window the current window (just as if you have clicked it yourself manually)
public static FormABC formABC;
if ((formABC != null && !formABC.IsDisposed)) return;
formABC = new FormABC { Owner = this };

Open in new window

All the forms should have been opened from one Parent form. You need to trigger an event or call a public member to make desired form to bring at the top level from Parent Form.

You can access the parent form by this.ParentForm...
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

amillyardAuthor Commented:
HarryNS: sorry...a little confused ...

I understand the concept of launching all WinForms from a main for etc.

but a bit lost with:  "You can access the parent form by this.ParentForm..."  

I know how to access the main WinForm -- just needed to know what triggers a window to become Top Level / active window
You still have a reference to formABC, right?
Easiest way is with

amillyardAuthor Commented:
Snarf0001:  I see.  Have applied suggestion -- I am getting the following compiling error as follows:

Cannot access non-static method 'Activate' in static context
Are you calling this from within a static function?
amillyardAuthor Commented:
Snarf0001:  You triggered a thought -- which resolved the issue -- I was not calling the WinForm from the right place -- i.e. from the source WinForm
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now