本文整理匯總了C#中System.Windows.Forms.ContainerControl.ActiveControl屬性的典型用法代碼示例。如果您正苦於以下問題:C# ContainerControl.ActiveControl屬性的具體用法?C# ContainerControl.ActiveControl怎麽用?C# ContainerControl.ActiveControl使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。
在下文中一共展示了ContainerControl.ActiveControl屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: MyContainer
//引入命名空間
using System;
using System.Windows.Forms;
using System.Drawing;
public class MyContainer : ScrollableControl, IContainerControl
{
private Control activeControl;
public MyContainer()
{
// Make the container control Blue so it can be distinguished on the form.
this.BackColor = Color.Blue;
// Make the container scrollable.
this.AutoScroll = true;
}
// Add implementation to the IContainerControl.ActiveControl property.
public Control ActiveControl
{
get
{
return activeControl;
}
set
{
// Make sure the control is a member of the ControlCollection.
if(this.Controls.Contains(value))
{
activeControl = value;
}
}
}
// Add implementations to the IContainerControl.ActivateControl(Control) method.
public bool ActivateControl(Control active)
{
if(this.Controls.Contains(active))
{
// Select the control and scroll the control into view if needed.
active.Select();
this.ScrollControlIntoView(active);
this.activeControl = active;
return true;
}
return false;
}
}