I love the new feature AutoDetectMdiChildForms, however, I can't seem to find a way to close the mdi form when the close button is clicked on the docking panel.
I see there is a non-public member of ManageedDockables called mdiChild. That holds the value of the form I am trying to close. What I'd like to know is if there is another way to get this value or can you make this member public?
I've searched all other mdichildren members I could find and all were null except this one.
I see there is a non-public member of ManageedDockables called mdiChild. That holds the value of the form I am trying to close. What I'd like to know is if there is another way to get this value or can you make this member public?
I've searched all other mdichildren members I could find and all were null except this one.
6 Answers, 1 is accepted
0
Hello Ken, in our upcoming release we will include a new property of DocumentPane object - MDIChild, which is used as a host of MDI child forms. Also some fixes related to Close/Closing events of IDockable document type windows will be introduced.
Currently you can use following code to achieve your goal:
Greetings,
Julian Benkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Currently you can use following code to achieve your goal:
private void button1_Click(object sender, EventArgs e) |
{ |
Form form = new Form(); |
form.Text = "Report1"; |
form.MdiParent = this; |
form.Show(); |
TextBox textBox = new TextBox(); |
textBox.Text = "Hello!"; |
textBox.Multiline = true; |
textBox.Dock = DockStyle.Fill; |
form.Controls.Add(textBox); |
DocumentPane pane = form.Parent as DocumentPane; |
if (pane != null) |
{ |
pane.Closed +=new EventHandler(pane_Closed); |
} |
} |
void pane_Closed(object sender, EventArgs e) |
{ |
DocumentPane docPane = sender as DocumentPane; |
if (docPane.Controls.Count > 0) |
{ |
Form form = docPane.Controls[0] as Form; |
//your logic should go here... |
} |
} |
Greetings,
Julian Benkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
KMBah
Top achievements
Rank 1
answered on 13 Jul 2007, 04:08 PM
EDIT: If you saw my earlier post please ignore. This is the updated version.
That looks like exactly what I'm looking for. One problem... the pane_Closed event never seems to fire.
Here's my relevant code.
That looks like exactly what I'm looking for. One problem... the pane_Closed event never seems to fire.
Here's my relevant code.
public frmMain() |
{ |
InitializeComponent(); |
pefrmMain = this; |
GoImage.DefaultResourceManager = new ResourceManager("ProductEditor.Properties.Images", this.GetType().Assembly); |
Shape = new RoundRectShape(10); |
BorderColor = Color.FromArgb(59, 90, 130); |
BackColor = Color.FromArgb(191, 219, 254); |
twRichEditor = new RichEditBoxToolwindow("Text Editor", true); |
this.dmMain.PrimarySite.SetDock(twRichEditor, DockPosition.Bottom); |
twTools = new ToolsWindow("Tools"); |
this.dmMain.PrimarySite.SetDock(twTools, DockPosition.Left); |
this.WindowState = FormWindowState.Maximized; |
} |
private void frmMain_Load(object sender, System.EventArgs e) |
{ |
twRichEditor.Size = new Size(twRichEditor.Width, 150); |
twTools.Size = new Size(200, twTools.Height); |
rmiNew_Click(this, null); |
rbeShowAll_Click(this, null); |
} |
private void rmiNew_Click(object sender, EventArgs e) |
{ |
frmView canvas = new frmView(); |
canvas.MdiParent = this; |
canvas.Show(); |
canvas.View.UpdateFormInfo(); |
DocumentPane pane = canvas.Parent as DocumentPane; |
if (pane != null) |
pane.Closed += new EventHandler(pane_Closed); |
} |
private void pane_Closed(object sender, EventArgs e) |
{ |
DocumentPane pane = sender as DocumentPane; |
if (pane.Controls.Count > 0) |
{ |
frmView frm = pane.Controls[0] as frmView; |
frm.Close(); |
} |
} |
0
KMBah
Top achievements
Rank 1
answered on 13 Jul 2007, 09:38 PM
I got it working with the below code. Seems to work fine with the minimal testing I've done. Now I have to figure out how to find the MDIChildren for another issue.
private void dmMain_DockingStateChanging(object sender, DockingChangingEventArgs e) |
{ |
if (e.DockObject is DocumentPane) |
{ |
if (e.PreviousDockableState == DockState.TabbedDocument |
&& e.DockableState == DockState.Default) |
{ |
DocumentPane dp = e.DockObject as DocumentPane; |
frmView frm = dp.Controls[0] as frmView; |
frm.Close(); |
} |
} |
} |
0
Hi Ken,
The DockingManager has a Form[] MdiChildren property which is the same as Form MdiChildren. It gets an array of forms that represent the multiple document interface (MDI) child forms that are parented to this docking manager.
The DockingManager also has a Documents collection, which gets the Controls collection of every item and then has access to the MdiChildren Form (usually the first element in the Controls collection):
Best wishes,
Julian Benkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The DockingManager has a Form[] MdiChildren property which is the same as Form MdiChildren. It gets an array of forms that represent the multiple document interface (MDI) child forms that are parented to this docking manager.
The DockingManager also has a Documents collection, which gets the Controls collection of every item and then has access to the MdiChildren Form (usually the first element in the Controls collection):
foreach(IDockable window in dockingManager1.GetManagedDockables()) |
{ |
DocumentPane dockPane = window as DocumentPane; |
if(dockPane != null) |
{ |
if(dockPane.Controls.Count > 0) |
{ |
//access to MDI child form |
Form childForm = dockPane.Controls[0]; |
} |
} |
} |
Best wishes,
Julian Benkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
KMBah
Top achievements
Rank 1
answered on 16 Jul 2007, 05:07 PM
For some reason the DockingManager.MidChildren is empty wherever I try to access it.
I got the MDI children in a very similar way to your code below... just a tad different.
I got the MDI children in a very similar way to your code below... just a tad different.
foreach (IDockable idoc in frm.dmMain.PrimarySite.ManagedDockables) |
{ |
if (idoc is DocumentPane) |
{ |
frmView w = ((DocumentPane)idoc).Controls[0] as frmView; |
if (w != null && w.Doc == doc) |
{ |
windows.Add(w); |
} |
} |
} |
0
Hello Ken,
Thank you for the additional details. They helped us identify a couple of issues related to the Documents collection. The fix is already in place and we can send it to you in case this is a showstopper. Simply open a support ticket and request the custom build.
Thank you for your assistance. Check your account for some extra Telerik points.
Regards,
Julian Benkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for the additional details. They helped us identify a couple of issues related to the Documents collection. The fix is already in place and we can send it to you in case this is a showstopper. Simply open a support ticket and request the custom build.
Thank you for your assistance. Check your account for some extra Telerik points.
Regards,
Julian Benkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center