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.
amillyardAsked:
Who is Participating?
 
Snarf0001Connect With a Mentor Commented:
You still have a reference to formABC, right?
Easiest way is with

 formABC.Activate()
0
 
DhaestCommented:
What kind of application do you have ?
A single or multiple document interface ?

Focus Form
http://www.java2s.com/Code/CSharp/GUI-Windows-Form/FocusForm.htm
0
 
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 };
formABC.Show();

Open in new window

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
HarryNSCommented:
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...
0
 
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
0
 
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
0
 
Snarf0001Commented:
Are you calling this from within a static function?
0
 
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
0
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.

All Courses

From novice to tech pro — start learning today.