Reputation: 59
This one has really got me stumped. I have certain forms that are being instantiated. When I instantiate a form i make it a child of the mdi form by
form1.MdiParent = this;
I have set the MDIWindowListITem property of my menustrip to a toolstripmenuitem
However this toolstripmenuitem does not show the mdi child form when it is instantiated
Does any one have any ideas on this?
Any inputs/ leads / hints would be most welcome. I am using .net framework 3.5
Regards
,
Upvotes: 1
Views: 2025
Reputation: 9209
You have to write your code so that it is added manually I believe.
See the example here for pointers:
Edit
You're right ignore my previous entry here's the code for a very simple MDI app that appears to do what your after.
It is just two blank forms. Form1 has IsMDIContainer=true
. It also has menuStrip1
, which contains two items "new" (newToolStripMenuItem
) and "windows" (windowsToolStripMenuItem
). Clicking new will open a new child window. I have set the MDIWindowListItem
of menuStrip1
to windowsMenuStripItem
. When a new child window is opened clicking on windowsMenuStripItem
produces a drop down that shows all windows open.
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private int count;
public Form1()
{
InitializeComponent();
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
count++;
//Set a window title text as this is what is shown in the window list.
Form2 newForm = new Form2() { Text = string.Format("Window {0}", count) };
newForm.MdiParent = this;
newForm.Show();//<--- this needed to show window in list.
}
}
}
There is no code in Form2.
The child windows only show below windowMenuStripItem
once Form.Show() has been called.
Without this they do not show in the list.
Upvotes: 1