-->

ASP.Net Tutorial

ASP.Net Tutorial for Beginners and Advanced users. You will get best tutorial related to C#,VB,SQL,Interview Questions

Best Solution :Form cannot be both an MDI child and MDI parent. Parameter name: value in Visual Studio

For opening One or More Windows Form inside another Windows form, a property called "IsMdiContainer" and "MdiParent" is used in below given phasion:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Education_Domain
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            IsMdiContainer = true;
         
        } private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 tr = new Form3();
            tr.Show();
            tr.MdiParent = this;
      }
        }
Most of the times, this code works but users also complains that they get an error "Form cannot be both an MDI child and MDI parent. Parameter name: value". Screenshot of the error screen is given below :

Solution:Form cannot be both an MDI Child and MDI Parent. Parameter name:value in Visual Studio

If you are looking for the solution of this error, simply follow below given procedure:
 Solution of this Problem::
For solving the issue of this problem, Simply add "objectname.MdiConatiner=false;" before the code "objectname.MdiParent=this;". The complete code is given below:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Education_Domain
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            IsMdiContainer = true;
            
        }

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 tr = new Form3();
            tr.IsMdiContainer = false; ---------solution code
            tr.MdiParent = this;
            tr.Show();
          }  
        }

That's all. Your problem will be fixed. If you are facing any other issue, let me know. I will fix that for you. 
Click To Visit Our Books Store
I have read some fantastic books on English language that really helped me improve my writing. You can buy my recommended books on Amazon. Here is the lists below:

Books on Grammar:
Books Buy Links Rating

The Elephants Of Style

4.5/5

English Grammar in Use Book

4.5/5

Practical English Usage

4.5/5

The Elements of Style

4.5/5

Essentials of English

4.5/5

Handbook of English Grammar and Usage

4.5/5

Woe Is I

4.5/5

Grammar Girl's Quick and Dirty Tips for Better Writing

4.5/5

It was the best of sentences, it was the worst of sentences.

4.5/5

If you want more books on English language, click the link



No comments:

Post a Comment



Looking for something? Find here!