ContainerControl 클래스
다른 컨트롤의 컨테이너로 작동할 수 있는 컨트롤에 대한 포커스 관리 기능을 제공합니다.
네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)
구문
‘선언
<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public Class ContainerControl
Inherits ScrollableControl
Implements IContainerControl
‘사용 방법
Dim instance As ContainerControl
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
public class ContainerControl : ScrollableControl, IContainerControl
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
public ref class ContainerControl : public ScrollableControl, IContainerControl
/** @attribute ComVisibleAttribute(true) */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
public class ContainerControl extends ScrollableControl implements IContainerControl
ComVisibleAttribute(true)
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
public class ContainerControl extends ScrollableControl implements IContainerControl
설명
ContainerControl은 다른 컨트롤의 컨테이너로 작동할 수 있는 컨트롤을 나타내며 포커스 관리 기능을 제공합니다. 다른 컨테이너 내부로 포커스가 옮겨져도, 이 클래스에서 상속하는 컨트롤은 내부에 포함된 활성 컨트롤을 추적할 수 있습니다.
ContainerControl 개체는 포함된 컨트롤에 대한 논리적 경계를 제공합니다. Tab 키를 누르면 해당 컨테이너 컨트롤에 의해 컬렉션 내의 다음 컨트롤로 포커스가 이동됩니다.
참고
컨테이너 컨트롤은 포커스를 받지 않으며, 포커스는 항상 포함된 컨트롤의 컬렉션에 있는 첫 번째 자식 컨트롤로 설정됩니다.
일반적으로 ContainerControl 클래스에서 직접 상속받지 않습니다. Form, UserControl 및 UpDownBase 클래스는 ContainerControl에서 상속받습니다.
예제
다음 코드 예제에서는 ScrollableControl 클래스에서 상속하여 IContainerControl 인터페이스를 구현합니다. ActiveControl 속성 및 ActivateControl 메서드에 구현이 추가됩니다.
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Public Class MyContainerControl
Inherits ScrollableControl
Implements IContainerControl
Private myActiveControl As Control
Public Sub New()
' Make the container control Blue so it can be distinguished on the form.
Me.BackColor = Color.Blue
' Make the container scrollable.
Me.AutoScroll = True
End Sub
' Add implementation to the IContainerControl.ActiveControl property.
Public Property ActiveControl() As Control Implements IContainerControl.ActiveControl
Get
Return Me.myActiveControl
End Get
Set
' Make sure the control is a member of the ControlCollection.
If Me.Controls.Contains(value) Then
Me.myActiveControl = value
End If
End Set
End Property
' Add implementation to the IContainerControl.ActivateControl(Control) method.
public Function ActivateControl(active As Control) As Boolean Implements IContainerControl.ActivateControl
If Me.Controls.Contains(active) Then
' Select the control and scroll the control into view if needed.
active.Select()
Me.ScrollControlIntoView(active)
Me.myActiveControl = active
Return True
End If
Return False
End Function
End Class
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;
}
}
using namespace System;
using namespace System::Windows::Forms;
using namespace System::Drawing;
public ref class MyContainer: public ScrollableControl, public 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;
}
property Control^ ActiveControl
{
// Add implementation to the IContainerControl.ActiveControl property.
virtual Control^ get()
{
return activeControl;
}
virtual void set( Control^ value )
{
// 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.
virtual 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;
}
};
import System.*;
import System.Windows.Forms.*;
import System.Drawing.*;
public class MyContainer extends ScrollableControl implements IContainerControl
{
private Control activeControl;
public MyContainer()
{
// Make the container control Blue so it can be
// distinguished on the form.
this.set_BackColor(Color.get_Blue());
// Make the container scrollable.
this.set_AutoScroll(true);
} //MyContainer
// Add implementation to the IContainerControl.ActiveControl property.
/** @property
*/
public Control get_ActiveControl()
{
return activeControl;
} //get_ActiveControl
/** @property
*/
public void set_ActiveControl(Control value)
{
// Make sure the control is a member of the ControlCollection.
if (this.get_Controls().Contains(value)) {
activeControl = value;
}
} //set_ActiveControl
// Add implementations to the IContainerControl.
// ActivateControl(Control) method.
public boolean ActivateControl(Control active)
{
if (this.get_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;
} //ActivateControl
} //MyContainer
상속 계층 구조
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ScrollableControl
System.Windows.Forms.ContainerControl
파생 클래스
스레드로부터의 안전성
이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.
플랫폼
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
.NET Compact Framework
2.0, 1.0에서 지원
참고 항목
참조
ContainerControl 멤버
System.Windows.Forms 네임스페이스
Form
UserControl
UpDownBase
IContainerControl
ScrollableControl