C # - How to deal with 2 "TopMost" forms?

I have a parent form that is set to TopMost, and then I have another form that opens when a button is clicked. This child form must also be TopMost. The first question I had was that when I open the child form, the application will basically freeze because you cannot access anything. I decided that instead of using ShowDialog () to open the child form, I would use Show (this). This fixed the original problem, but now I have a new one. The initial postulate of childforms is set to CenterParent, and when I use Show (this), it does not work. Is there a way to make a child form open when both it and the parent form are set to the very top when the childforms start position is set to CenterParent? Thanks.

+3
source share
3 answers

You can try to clear the TopMost property of the parent form for as long as the view of the child form is.

This will solve the problem of which shape should be the largest, since it will only ever be.

+3
source

I found something useful to share with you guys. Instead of the following code

form2.TopMost = true;

use this code in the main form:

form2.Owner = this;

If you use the Form.TopMost property, the form will overlap all other not topmost forms, but also other applications. Instead, set the Form.Owner property to the parent form — the one that should be in the form (for example, in the main form). Good luck with the G00d :)

+2
source

. . TopMost = true . new Form2().ShowDialog();

. Form2 . Form1 , ShowDialog

. 2 .

, - ?

0
source

Source: https://habr.com/ru/post/1721127/


All Articles