Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4587462
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:47:03+00:00 2026-05-21T21:47:03+00:00

Actually Its my first project. While I want to convert my VB.Net2008 to C#2010

  • 0

Actually Its my first project. While I want to convert my VB.Net2008 to C#2010 I have few clarification pls.

In Form2 Properties I set – IsMDIContainer = True. Then the below code to open my MdiChild and now what is my problem when I click the close button, it’s also closing the MDIParent. But I need to close only mdichild… for that I tried as like Vb.Net2008 style by the following codes placed in MDIParent Form2, Its not working. Any right directions …

private void toolStripButton1_Click(object sender, EventArgs e)
{
  Form3 NwMdiChild2 = new Form3;
  NwMdiChild2.MdiParent = this;
  NwMdiChild2.Dock = System.Windows.Forms.DockStyle.Fill;
  NwMdiChild2.Show();
}

private void Form2_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
{
  Form[] MdiChildForms = this.MdiChildren;
  int kkk1 = MdiChildForms.Length;
  int x = 0;
  for (x = 0; x <= MdiChildForms.Length - 1; x += 1) 
  {
    if (MdiChildForms[x].Name == "Form1")
    {
      kkk1 = kkk1 - 1;
    }
    MdiChildForms[x].Close();
  }
  if (kkk1 > 0) 
  {
  // For Not Closing
  e.Cancel = true;
  }
  else
  {
    // For Closing
    e.Cancel = false;
    Application.Exit();
  }
}

Any Right Directions for Me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:47:04+00:00Added an answer on May 21, 2026 at 9:47 pm

    I’m not sure if I understand well what you want to achieve: do you want, when click Parent Form close button, insteed of closing parent form, to close all the child’s form? Form2 is your main form (parent MDI container), Form3 is the MDI children, isn’t it?
    Please try following code and tell if it’s what you are asking for:

    private void toolStripButton1_Click(object sender, EventArgs e)
    {
        Form3 NwMdiChild2 = new Form3();    //don't forget ()
        NwMdiChild2.MdiParent = this;
        NwMdiChild2.Dock = System.Windows.Forms.DockStyle.Fill;
        NwMdiChild2.Show();
    }
    
    private void Form2_FormClosing(object sender, FormClosingEventArgs e)
    {
        //if no MDI child - this is going to be skipped and norlmal Form2 close takes place
        if (this.MdiChildren.Length > 0)    //close childrens only when there are some
        {
            foreach (Form childForm in this.MdiChildren)
                childForm.Close();
    
            e.Cancel = true;  //cancel Form2 closing
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XSLT Transformer in Java (actually its Apache FOP rendering to PDF)
I want to preprocess files before gcc actually does its own preprocessing and parsing.
Its regarding QTP can we create database checkpoints for Web applications actually while creating
I am trying to convert my model-first project to code-first, as I can see
I have issues setting up my deployment project in Visual Studio 2010. Im using
I have a project which is under source control using TFS. Actually, I have
Hello First sorry for my english. I have started recently my first project on
I am using a sliding drawer on my application (actually its a Panel). I
I'm quite new to Flex and wondered if other developers actually use its stylesheet
Actually it's a lot easier to show you what I want to achieve instead

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.