TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Bring a form to the front

C#(C Sharp)

 
 
Thread Tools Display Modes
Unread 24-09-2007, 08:40 PM   #1
Alistair George
Guest
 
Posts: n/a
Bring a form to the front

Having a bit of a battle here with getting a form on instantiation to
the front. EG the user would think that it was not running because the
window is hidden behind eg explorer. This works:

private void frmMain_Shown(object sender, EventArgs e)
{
// Make this form the active form and make it TopMost
this.ShowInTaskbar = false;
this.TopMost = true;
this.Focus();
this.BringToFront();
}
But, it leaves the window permanently in front of all windows. In
delphi, we say bringtofront, and it does just that, but in C#
bringtofront seems a bit flakey, and topmost is too invasive.
Thanks. Al.
 
Unread 24-09-2007, 08:47 PM   #2
zacks@construction-imaging.com
Guest
 
Posts: n/a
Re: Bring a form to the front

On Sep 24, 3:12 pm, Alistair George <non...@xtra.co.nz> wrote:
> Having a bit of a battle here with getting a form on instantiation to
> the front. EG the user would think that it was not running because the
> window is hidden behind eg explorer. This works:
>
> private void frmMain_Shown(object sender, EventArgs e)
> {
> // Make this form the active form and make it TopMost
> this.ShowInTaskbar = false;
> this.TopMost = true;
> this.Focus();
> this.BringToFront();
> }
> But, it leaves the window permanently in front of all windows. In
> delphi, we say bringtofront, and it does just that, but in C#
> bringtofront seems a bit flakey, and topmost is too invasive.
> Thanks. Al.


Why not just re-set TopMost back to false after the .BringToFront?

 
Unread 25-09-2007, 03:32 AM   #3
Alistair George
Guest
 
Posts: n/a
Re: Bring a form to the front


> Why not just re-set TopMost back to false after the .BringToFront?
>

Yes, works cheers:
private void frmMain_Shown(object sender, EventArgs e)
{
// Make this form the active form and make it TopMost
this.ShowInTaskbar = false;
this.TopMost = true;
this.Focus();
this.BringToFront();
this.TopMost = false;
}
 
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fore Front Updates Eran.B Windows Security 4 14-09-2007 09:25 PM
Front Page 2000 Rustydog Microsoft Office 2 28-08-2007 10:49 AM
Front page express question Jim Shiller Windows Server 2003 0 27-08-2007 10:54 PM
Microsoft Office XP Pro with Front Page Even Stephen Windows XP 11 27-08-2007 05:45 PM
Publishing from Front Page 2003 Rounick Windows Vista All 5 19-08-2007 10:31 PM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 09:38 AM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional