How to use MdiContainer

This is what I usually do when I want to open a new form from a ToolStripMenu

private void alumnoToolStripMenuItem_Click(object sender, EventArgs e)
    {
        frmAlumno x = new frmAlumno();
        x.ShowDialog();
    }

but a teacher told me that it´s wrong because this shouldn´t happen..

So I guess I have to use MdiContainer but I´m not sure of how to write the code now... Please some help...

Answers


If you use MDI, you should call Show, not ShowDialog. Also you need to set MdiParent.

Form2 newMDIChild = new Form2();

// Set the Parent Form of the Child window.
newMDIChild.MdiParent = this;

// Display the new form.
newMDIChild.Show();

How to: Create MDI Child Forms


I'm going to answer with a solution to your actual problem instead of describing how to use MdiContainer, since you don't actually need it. :)

Forms have a ShowInTaskbar property that defaults to true. Set it to false and the form will no longer appear in the task bar.

private void alumnoToolStripMenuItem_Click(object sender, EventArgs e)
{
    frmAlumno x = new frmAlumno();
    x.ShowInTaskbar = false;
    x.ShowDialog();
}

See MSDN for more information.


Introduction to MDI Forms with C#


Need Your Help

Non-terminating recursive use of decltype

c++ templates c++11 recursion

Compilation of the following code has problems due to infinite compile-time recursion. Clang 3.6.0 gives an error about recursive template instantiation depth, and doesn't terminate; while GCC 4.9.2

String array in C++ not working properly?

c++ arrays string

I'm working on a program for class that takes in a number from 0 to 9999, and spits out the word value (ie 13 would be spit out as "thirteen", etc) And I'm having a pain with the array for some re...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.