Reputation: 9610
I am using Dockpanel-suite and I have basically 3 forms open. One of these is a "Document" form which can have multiple documents open, where as the other two forms are single instances.
At some stage I want to find and close some of the document forms. Now according to the documentation for dockpanel-suite it states
Remove a DockContent From DockPanel To release a DockContent from DockPanel, simply set DockContent.DockHandler.DockPanel to null.
But DockHandler is readonly, so I can't set it to null So how can I find the documents I need and perform actions on these, such as close them?
At the moment I am doing this;
foreach (DockContent dock in this.dockPanel1.Documents)
{
if (dock.GetType() == typeof(FormQueryBuilder))
{
FormQueryBuilder qb = (FormQueryBuilder)dock;
string number = qb.TabText.Replace("Query ", ""); //close all documents except those which start "Query 1"
if (Convert.ToInt32(number) > 1)
{
dock.Close();
}
}
}
Strangely, if I call dock.Close() this will close the document, but if this is called during "FormClosing" event of my main (containing) form then it stops my form being closed. It seems to be setting some value to cancel this!
Upvotes: 1
Views: 324