Posted 19 years ago by jeffrap - USA
Avatar
I get an error when I reload the layout file how do I really "clear it"?

private void mnuLoad_Click(object sender, System.EventArgs e)
{

dwManager.Controls.Clear();
dwManager.ClearLayout();
dwManager.Refresh();
string layoutFileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Layout1.txt");

try
{
dwManager.LoadLayoutFromFile(layoutFileName);
}
catch (Exception ex)
{
MessageBox.Show (ex.Message.ToString());
}
}

Comments (7)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Just call ClearLayout. Don't do any of that other stuff.


Actipro Software Support

Posted 19 years ago by jeffrap - USA
Avatar
Ok, I did that, I removed the code now it is:

-------------------------

private void mnuLoad_Click(object sender, System.EventArgs e)
{
dwManager.ClearLayout();
string layoutFileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Layout1.txt");

try
{
dwManager.LoadLayoutFromFile(layoutFileName);
}
catch (Exception ex)
{
MessageBox.Show (ex.Message.ToString());
}
}

-----------------------------------

I run this proceedure 2x, the first time it works, the second time i get the following error:

"Two or more controls existed on main form with the name "EntityHierarchy". The dockable window manager does not know which one to use. Please name these controls uniquely. Parameter name : child name"

What do I do so it wont throw the error? I basically want to reload a "standard" layout if I change things and close windows etc, I would like to get back to the original layout.

Thanks,

Jeff
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
It sounds like you are creating a control named EntityHierarchy twice. You should find the code that creates that control and only create it once.


Actipro Software Support

Posted 19 years ago by jeffrap - USA
Avatar
I have two objects that I create from that class. Again, I can run this function 1 time with no problem (to load the window panes the first time). When I call this function a second time, the error occurs.
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
What happens is that there are apparently two controls with that same name. When the layout is loading, it's looking for a tool window child control of that name however since there are two, it doesn't know which one to pick. You can either rename one of them before loading the layout, or handle the GetToolWindowChild event instead.

If you'd like to handle the event to specify which control to use, set the DWManager.RequireUniqueNamesForChildControls property to false. That will stop the exception from firing.

Also, FYI, the rewrite of docking controls that we're working no longer has these sorts of issues to deal with.


Actipro Software Support

Posted 19 years ago by jeffrap - USA
Avatar
I just put that property RequireUniqueNamesForChildControls to false, and all seems to work fine now... Is that it?

Jeff
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Well if that property is false, it will use one the controls with the name "EntityHierarchy" as a tool window child and won't touch the other. The exception is normally thrown to prevent you from accumulating multiple instances of tool window child controls with the same name.

As long as you only create two instances of your EntityHierarchy control, I suppose it is ok. You'll just have one in use as a tool window child and another in limbo.


Actipro Software Support

The latest build of this product (v2.0.0208) was released 19 years ago, which was after the last post in this thread.