Home Forums WinForms controls Other WinForms controls DockLayoutManager Floating Window Closed event

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18508 |

    I would like to remove floating window from DockLayoutManager in the event of Tool Window’s closed

    i.e .

    var window = new ToolWindow(spy, id);
    window.Closed += window_Closed;

     void window_Closed(object sender, EventArgs e)
    {
                ToolWindow window = (ToolWindow) sender;
                 dockLayoutManager1.ToolWindows.Remove(window);  
    }

     

    I encountered this error when I tried to close the window : 

    “Collection was modified; enumeration operation may not executeat Xceed.Utils.Collections.ListBase.Enumerator.MoveNext()\r\n   at Xceed.DockingWindows.FloatingWindow.OnFloatingWindowClosed()  
    at Xceed.DockingWindows.FloatingWindow.WndProc(Message& m)………………….”

     And it happens ONLY if I try to close Floating window. It works fine for other type of tool windows.

    Anyone has any idea? Any suggestion/idea would be appreciated.

     

    Imported from legacy forums. Posted by Taz Devil (had 3989 views)

    User (Old forums)
    Member
    Post count: 23064

    We have reproduced the issue, and we are looking at this.  We will let you know when we have more information.

    Imported from legacy forums. Posted by André (had 380 views)

    User (Old forums)
    Member
    Post count: 23064

    There is a workaround for this problem, by making the Remove() happen later : 

     void window_Closed(object sender, EventArgs e)
    {
                ToolWindow window = (ToolWindow) sender;
                this.BeginInvoke( new MethodInvoker( delegate() { dockLayoutManager1.ToolWindows.Remove( window ); } ) );
    }

     

    Imported from legacy forums. Posted by André (had 680 views)

    User (Old forums)
    Member
    Post count: 23064

    Yep – I just encountered this issue too – used a similar solution to yours posted (just a static version)

     

            private static void GridVirtualUserControl_Closed(object sender, EventArgs e)

            {

                ToolWindow window = (ToolWindow)sender;

                window.BeginInvoke(new MethodInvoker(delegate() { window.DockLayoutManager.ToolWindows.Remove(window); }));

            }

    Imported from legacy forums. Posted by James (had 4051 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.