Solved

bring a WinForm into focus

Posted on 2009-04-01
8
567 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
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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 22

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 22

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
DataGridView 2 29
Visual Studio installation 5 39
Is IHttpActionResult a promise pattern? 2 37
.Net Web Site Password specs 2 21
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now