Child form is in front of everything including other windows Windows Forms C#

Asked

Viewed 432 times

1

I need my child Forms to stand in front of the parent form, up to there blz. Only they stand on top of any other window or program. I wonder if there are ways the child Forms stay only in front of the parent form and when other windows or programs are opened they do not get in front.

Code that opens the child form

  FormCadastroCliente formCli;
    private void BtnCliente_Click(object sender, EventArgs e)
    {
        bool _found = false;
        foreach (Form _openForm in Application.OpenForms)
        {
            if (_openForm is FormCadastroCliente)
            {
                _openForm.Focus();
                _found = true;
            }
        }

        if (!_found)
        {
            formCli = new FormCadastroCliente();
            formCli.Show();
            formCli.BringToFront();
            formCli.TopMost = true;
        }
    }
  • Try to take out Topmost = true and leave only Bringtofront();

  • 1

    if the intention is not to let access the parent form, while the child is open, where you open the child form, change formCli.Show(); for formCli.ShowDialog();

  • The two suggestions already tried, what happens is if I take the Topmost and click on the parent form the son form falls behind, if I exchange Show for showDialog while a child form is open I can not click anything in the parent form.

  • and what the goal after all ?

  • The goal already achieved: Open the parent form, after that open one or more son Forms. Child Forms are always in front of the parent form even by clicking on the parent form. Now the main goal: When you have one or more child forms already opened and open a windows folder for example, I want the child form opened behind the open folder (which is not happening) The child forms are above everything, all the same.

  • "while a child form is open I can not click anything in the parent form" but you want the form in front of the parent... how q will click something ?! similarly... if the son has to be in front of the father... as q will open "one or more Forms son"? ?

  • It’s a Rovann system, I can open up client records and product records at the same time. The way I made this working as I want, only that the son Forms are in front of everything, any window, I just want to solve this.

  • 1

    so dude... the behavior of the Forms is the same as other windows windows... or she’s TopMost who will stand in front of everything... or is Modal that "stands in front of all windows of the application, waiting for a user response" or is a normal form, and will be in front of the active form... there is also mdi Child, but I think it does not apply to the case

  • https://msdn.microsoft.com/pt-br/library/39wcs2dh%28v=vs.110%29.aspx? f=255&Mspperror=-2147217396

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.