0

I am new in window application and I am not able to render another window form after saving data to database. here is my code I am opening the another window form

GameList gamelist = new GameList();// the form which I want to open
gamelist.MdiParent = new FrmAdmin();// FrmAdmin is main parent form
gamelist.WindowState = FormWindowState.Maximized;
gamelist.Show();

But I am getting this error message:

Form that was specified to be the MdiParent for this form is not an MdiContainer.

any help will be very thankful.

Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
Manish Kumar
  • 595
  • 2
  • 5
  • 20

2 Answers2

1

I think the problem is that you're using a MdiParent that is not visible (since you're creating a new one). Try removing this line:

gamelist.MdiParent = new FrmAdmin();// FrmAdmin is main parent form

and see if the form is displaying correctly.

If you want to show the GameList form inside a MdiParent, you have to use a Form that is already visible.

EDIT:

Looking at your comment, if you're trying to show the GameList form inside the current form, try this:

this.IsMdiContainer = true;
GameList gamelist = new GameList();// the form which I want to open
gamelist.MdiParent = this;// FrmAdmin is main parent form
gamelist.WindowState = FormWindowState.Maximized;
gamelist.Show();
LucaMus
  • 721
  • 7
  • 17
1

You need to set the IsMdiContainer of the parent form to True and also change new FrmAdmin(); to this and try again:

public FrmAdmin()
{
    InitializeComponent();
    IsMdiContainer = true;
}

GameList gamelist = new GameList();
gamelist.MdiParent = this;
gamelist.WindowState = FormWindowState.Maximized;
gamelist.Show();
Salah Akbari
  • 39,330
  • 10
  • 79
  • 109