Solved

bring a WinForm into focus

Posted on 2009-04-01
8
580 Views
Last Modified: 2013-12-17
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.
0
Comment
Question by:amillyard
[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
8 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24038033
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
 

Author Comment

by:amillyard
ID: 24038280
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
 
LVL 6

Expert Comment

by:HarryNS
ID: 24038975
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:amillyard
ID: 24040310
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
 
LVL 23

Accepted Solution

by:
Snarf0001 earned 500 total points
ID: 24040837
You still have a reference to formABC, right?
Easiest way is with

 formABC.Activate()
0
 

Author Comment

by:amillyard
ID: 24041325
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
 
LVL 23

Expert Comment

by:Snarf0001
ID: 24041404
Are you calling this from within a static function?
0
 

Author Comment

by:amillyard
ID: 24041639
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

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 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