Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

bring a WinForm into focus

Posted on 2009-04-01
8
Medium Priority
?
583 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
URL rewriting in AWS CloudFront

A quick how-to guide to implement with a Lambda function!

 

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 2000 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

Google Certified Professional - Cloud Architect

This course (1 of 3) is designed to help students who are interested in Google Cloud Platform (GCP) to become familiar with the platform, navigate the console and learn its capabilities. It will also prepare students for the Google Cloud Architect certification exam.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

718 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