0

I have a form which contains some stuff (buttons, labels, pictures...). When the first form is shown, a second form will load, containing a label. If I now move the mouse over a control on the first form, the label on the second form will show information about that. Or at least thats what I want to happen. But i just dont know how I could do it that the second form will still be shown and not minimized when I click things in form1.

Is there any way to keep the second form visible while doing things in form 1?

EDIT: Maybe I said wrong what I meant, I just want the second form to be shown while I still can do things on form 1.

Tim Kathete Stadler
  • 1,067
  • 4
  • 26
  • 52
  • So you want the second form to always be on top of your form, but you presumably don't want it to steal focus when it does so, and I (hope) you don't want it to always be on top of any other application's windows. – Servy Feb 06 '13 at 19:48
  • I just want it to be visible. – Tim Kathete Stadler Feb 06 '13 at 19:50
  • That's entirely unhelpful and isn't nearly specific enough to be answerable. – Servy Feb 06 '13 at 19:50
  • Take a look at this thread, it looks very similar [Keep window on top and steal focus in WinForms](http://stackoverflow.com/questions/278237/keep-window-on-top-and-steal-focus-in-winforms). – Dmitriy Konovalov Feb 06 '13 at 19:54
  • 1
    It seems as if you're trying to re-implement tooltips. What's wrong with the tooltip system that's already available? You can extensively customise their appearance, if needed. –  Feb 06 '13 at 19:55
  • @DmitriyKonovalov The difference is that's ensuring the window is on top of every other window in the entire machine, and prevents focus from being stolen from any other window on the machine. It appears that he only needs to ensure that one form is always above another form *in his application* and that it doesn't steal focus from the main form in the process, i.e. a tooltip, as hvd has said. – Servy Feb 06 '13 at 19:57

2 Answers2

2

look for the TopMost property and set it to TRUE

  • 1
    This would place it above windows in other applications which may not be desirable. It also wouldn't prevent the form from being closed or minimized. – Servy Feb 06 '13 at 19:51
2

You should use the overload of Form.Show method that takes an argument. The form owner. When you need to show the second form (for example an instance of Form2) inside the code of the first form (Form1=this) call

Form2 f = new Form2();
f.Show(this);

In this way the property Owner of the instance of Form2 is set to the current instance of Form1. This will keep the instance of Form2 on top of the instance of Form1

Steve
  • 213,761
  • 22
  • 232
  • 286