473,395 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.
Sep 24 '07 #1
2 24638
On Sep 24, 3:12 pm, Alistair George <non...@xtra.co.nzwrote:
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?

Sep 24 '07 #2
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;
}
Sep 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tyson | last post by:
I have got this little piece of code that fires on exit of a text box. It run's my query perfectly based of my form input. But I don't know how to bring result in my query back to a text box on my...
7
by: tom | last post by:
Hi, I want a listbox below a hidden calendar control. The problem is that the listbox will shadow the calendar when the calendar is visible. How can I bring the calendar from back to front? ...
2
by: Don | last post by:
I have two programs. One is supposed to bring the other (which is already running either minimized or at the bottom of the window z-order) to the front so that it becomes the foremost application....
2
by: JohnR | last post by:
Let's say I have an MDI parent form with a textbox. If I create an MDI child form and, at runtime, move the MDI child window over the textbox on the MDI parent, the textbox appears in front of the...
2
by: James | last post by:
Hi all, I am new to VB.NET. My program has two forms, if user clicks an "OK" button in Form1, the From2 will be brought to front. I found there are three methods of the Form class related to...
3
by: M O J O | last post by:
Hi, I have an application where I've implemented a global hotkey, so no matter what other application is in front (have focus), my app will react when the key combination is pressed. This works...
5
by: Iain Bishop | last post by:
I have a simple form with 4 command buttons and 1 label. The label is sometimes visible and sometimes not. When it is visible I want it to be in front of the buttons. I've tried bringing the label...
1
by: Marcel Brekelmans | last post by:
Hello, I have an application with a notifyIcon. When my application's main form is hidden by some other window I would like to bring it in front by single-clicking the NotifyIcon. However, I...
0
by: SAL | last post by:
Hello, I'm having trouble bringing a window to the front of all windows in an application I'm building. Actually, it's two applications that communicate via .NET Remoting. I'm trying to get the...
2
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I asked here yesterday about bringing a form to front with hotkey while using different application then mine (meaning, when i'm using outlook, and pressing ALT+T it will bring a form from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.