Jump to content

Close MDI by child

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
17 replies to this topic

#1
Keuvie

Keuvie

    Newbie

  • Members
  • PipPip
  • 13 posts
Good evening everyone,

I want to close a MDI and all het children from inside an child.

Is this possible?

this.Close() doesn't work.

#2
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
this.MDIParent.Close().
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#3
Keuvie

Keuvie

    Newbie

  • Members
  • PipPip
  • 13 posts
Thanks

#4
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Once again, you're welcome. Always happy to help. :)
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#5
Keuvie

Keuvie

    Newbie

  • Members
  • PipPip
  • 13 posts
This text is in a child and doesn't close the Parent, BUT when this.Close(); is this.Mdiparent.close(); it does work

private void btnOk_Click(object sender, EventArgs e)
        {
            if ((tbPass.Text == PasswordReal) && (tbUser.Text == UsernameReal))
            {
                this.Close();
            }
            else
            {
                {
                    DialogResult result = MessageBox.Show("Username and/or Password are incorrect. Enter again?", "Incorrect", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                    if (result == DialogResult.Retry)
                    {
                        tbPass.Text = "";
                        tbUser.Text = "";
                    }
                    else if (result == DialogResult.No)
                    {
                        this.MdiParent.Close();

                    }
                }
            }


#6
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Why, what happens?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#7
Keuvie

Keuvie

    Newbie

  • Members
  • PipPip
  • 13 posts
uhm, nothing :P

#8
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Try this:


MessageBox.Show("Xav's line of code was the problem.");

this.MDIParent.Close().


Run the project. If the message is shown, then my code is the problem. If not, it's your code.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#9
Keuvie

Keuvie

    Newbie

  • Members
  • PipPip
  • 13 posts
When there is no password i get your messagebox
private void btnOk_Click(object sender, EventArgs e)
        {
            if ((tbPass.Text == PasswordReal) && (tbUser.Text == UsernameReal))
            {
                this.Close();
            }
            else
            {
                MessageBox.Show("Xav's line of code was the problem.");
                this.MdiParent.Close();
                
                    /*DialogResult result = MessageBox.Show("Username and/or Password are incorrect. Enter again?", "Incorrect", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                    if (result == DialogResult.Retry)
                    {
                        tbPass.Text = "";
                        tbUser.Text = "";
                    }
                    else if (result == DialogResult.No)
                    {
                        
                    }*/
                
            }


#10
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
And with my message, does it close the parent form afterwards?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#11
Keuvie

Keuvie

    Newbie

  • Members
  • PipPip
  • 13 posts
i get your messagebox and then it closes the parent

#12
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Isn't that what you want?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums