开发者

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.ShowDial开发者_Go百科og();
    }

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

How to use MdiContainer

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


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#

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜