Problem with BringToFront()

C

C# Learner

BringToFront() has the desired effect in my app if the notify icon's
(system tray icon's) context menu is used. However, I can't
BringToFront() in response to a Click event handler.

Here's the code:

private void showContextMenuItem_Click(object sender,
System.EventArgs e)
{
DoShow(); // BringToFront() in DoShow() will work here.
}

private void notifyIcon_Click(object sender, System.EventArgs e)
{
DoShow(); // BringToFront() in DoShow() DOES NOT work here.
}

private void DoShow()
{
Show();

if (WindowState == FormWindowState.Minimized) {
WindowState = FormWindowState.Normal;
}
BringToFront();
}

Anyone have an idea?
 
C

C# Learner

<snip>

Fixed it! Here's the new DoShow() method that works:

private void DoShow()
{
if (WindowState == FormWindowState.Minimized) {
WindowState = FormWindowState.Normal;
}
Activate();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top