Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I try in C# Windows Form Project to bring opened form to top, Opened from Tool Strip Menu, beep and lock.
Can somebody help me with this problem.
David.
C#
private void openFlToolStripMenuItem_Click(object sender, EventArgs e)
{
  Application.OpenForms["MainForm"].BringToFront();
}

private void positionsBalanceToolStripMenuItem_Click(object sender, EventArgs e)
{
  Positions_Balance p_b = new Positions_Balance();
  p_b.ShowDialog();
  p_b.BringToFront();
}

private void ordersToolStripMenuItem_Click(object sender, EventArgs e)
{
  Orders o = new Orders();
  o.ShowDialog();
  o.BringToFront();
}

private void symbolLookupToolStripMenuItem_Click(object sender, EventArgs e)
{
  Symbol_Lookup s_l = new Symbol_Lookup();
  s_l.ShowDialog();
  s_l.BringToFront();
}


What I have tried:

I tried , what I find , but it's not the right C# source code.
Posted
Updated 24-Jan-17 8:15am
v2
Comments
Kornfeld Eliyahu Peter 24-Jan-17 13:22pm    
Do you mean to make the newly opened form to a top-level-window?
Member 12288840 7-Feb-17 22:18pm    
Where are the Gurus, I just remove Dialog, only Show(): Work fine

1 solution

When you call ShowDialog on a form, it creates what is called a Modal Dialog - which means that it overrides all existing forms in the application, and they do not respond to user input until the new form has been closed. Until then, you cannot set any other form as the "front" form because that is the one that will receive the keyboard input.

From the sample code you show, you seem to have Modal Dialogs there allready - and they dont; really exist as forms by the time you call BringToFront on them as they have to be closed in order to return control to the original code after the ShowDialog call.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900