By default, RadMenuItems are not supposed to have a close button. However, it is possible to achieve your requirement. You can add a button to the Children collection of the RadMenuItem and get the form associated with this menu. I prepared a sample example. Feel free to extend or modify it as per your needs.
publicRadForm1()
{
InitializeComponent();
this.IsMdiContainer = true;
this.radMenuItem1.MdiList = true;
Form child1 = new Form();
child1.Text = "Standard Windows Form1";
child1.MdiParent = this;
child1.Show();
Form child2 = new Form();
child2.Text = "Standard Windows Form2";
child2.MdiParent = this;
child2.Show();
}
protectedoverridevoidOnShown(EventArgs e)
{
base.OnShown(e);
foreach (RadMenuItem item inthis.radMenuItem1.Items)
{
Form f = typeof(RadMenuItem).GetField("mdiChildFormToActivate", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(item) as Form;
if (f != null)
{
RadButtonElement button = new RadButtonElement();
button.Text = "X";
button.StretchHorizontally = false;
button.Alignment = ContentAlignment.MiddleRight;
button.Tag = f;
button.Click += this.Button_Click;
item.Children.Add(button);
}
}
}
privatevoidButton_Click(object sender, EventArgs e)
{
RadButtonElement btn = sender as RadButtonElement;
if (btn.Tag!=null)
{
((Form)btn.Tag).Close();
}
}
I hope this helps. If you have other questions please let me know.
Thanks Nadya. Instead of the OnShown event handler (which was not working for me as children forms are opened by the user at runtime), I have the DropDownOpening event of my Window menu.