如何在运行时在C#.net中从MDI父级加载的用户控件中找到MDI父级的活动子窗体? [英] How to find the active child form of MDI parent from User control which is loaded in MDI Parent at runtime in C#.net?

查看:51
本文介绍了如何在运行时在C#.net中从MDI父级加载的用户控件中找到MDI父级的活动子窗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IDE: Microsoft Visual Studio

平台: C#.net

我正在尝试从运行时加载的用户控件中获取MDI父级的活动MDI子级的实例.

Hi, I am trying to get the instance of active MDI child of MDI parent from user control which is loaded at runtime.

推荐答案

在MDI父表单的代码中的任何位置,您都可以使用:

From anywhere within your MDI parent form's code, you can use:

Form activeChild = this.ActiveMdiChild;

这将为您提供当前集中(激活)的子表单的表单实例.每次打开新的子窗体时,或者当用户单击(聚焦)另一个子窗体时,它都会改变.

That will give you the form instance of the currently focused (activated) child form. It will change each time a new child form is opened, or when the user clicks (focuses) a different child.

MSDN页面

这篇关于如何在运行时在C#.net中从MDI父级加载的用户控件中找到MDI父级的活动子窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆