开发者

c# MDI Parent check child forms opened

开发者 https://www.devze.com 2023-04-11 20:15 出处:网络
I\'m making a MDI windows forms app and I have a panel inside the parent. Everytime I open one child I set the parent\'s panel visible=false with 开发者_StackOverflowthe event: MdiChildActivate. But w

I'm making a MDI windows forms app and I have a panel inside the parent. Everytime I open one child I set the parent's panel visible=false with 开发者_StackOverflowthe event: MdiChildActivate. But when I close all the childs I would like to set the parent's panel to visible=true.

Is there any way to do this?

Thanks a lot, maybe is a noob question, but I don't find anything.


Why not just subscribe to the Mdi child's Closed event and then check if there are any remaining children?

void CreateMdiForm()
{
    var child = new SomeMdiChildForm();
    // do stuff
    child.FormClosed += child_Closed;
}

void child_Closed( object sender, FormClosedEventArgs e )
{
    if( MdiChildren.Length == 0 )
    {
        SetPanelVisible();
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消