Home > C# > How to Determining the Active MDI Child

How to Determining the Active MDI Child

There are situations wherein we need to work with the active MDI child window from a group of opened MDI child windows. In such situation .NET provides “ActiveMDIChild” property which returns the child form that has the focus or that was nost recently active.

From the example given below, we have an MDI parent form (MDIParent1.cs) and assume that we have one or more child windows. the following code to retrieve the active MDI Child is: “this.ActiveMdiChild;”

// Determine the active child form.
Form activeChild = this.ActiveMdiChild;

// If there is an active child form, do 
if (activeChild != null)
{
	
}

In the event to iterate among the availabe MDI child windows, we use “this.MdiChildren”:

foreach (Form child in this.MdiChildren)
{

}
Advertisements
Categories: C# Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: