IContainerControl IContainerControl IContainerControl IContainerControl Interface

정의

다른 컨트롤에 대한 부모로 동작할 컨트롤에 대한 기능을 제공합니다.Provides the functionality for a control to act as a parent for other controls.

public interface class IContainerControl
public interface IContainerControl
type IContainerControl = interface
Public Interface IContainerControl
파생

예제

다음 예제에서 상속 되는 ScrollableControl 클래스 및 구현을 IContainerControl 인터페이스입니다.The following example inherits from the ScrollableControl class and implements the IContainerControl interface. 구현에 추가 되는 ActiveControl 속성 및 ActivateControl 메서드.Implementation is added to the ActiveControl property and the ActivateControl method.

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;
   }
};
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;
		}
	}
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  

구현자 참고

컨트롤 컬렉션의 부모를 지정할 클래스에서이 인터페이스를 구현 합니다.Implement this interface in classes that you want to parent a collection of controls. 이 인터페이스의 멤버를 사용 하면 자식 컨트롤을 활성화 또는 현재 활성 상태인 컨트롤을 확인할 수 있습니다.The members of this interface allow you to activate a child control, or determine which control is currently active. 클래스 ActivateControl(Control) 에서 구현 되는 Control 경우를 매개 변수로 사용 하 고 지정 된 컨트롤을 활성화 합니다.When implemented in a class, ActivateControl(Control) takes a Control as a parameter and activates the specified control. ActiveControl 속성 활성화 또는 활성화 된 컨트롤을 검색 합니다.The ActiveControl property activates or retrieves the control that is active.

가장 일반적인 시나리오를 직접이 인터페이스를 구현할 필요가 없습니다.In most common scenarios, you do not need to directly implement this interface. 예를 들어, Windows 컨트롤 라이브러리 프로젝트를 만드는 경우 Visual Studio는 초기 클래스를 생성 합니다.For example, if you create a Windows Control Library project, Visual Studio generates an initial class for you. 이 클래스는 UserControl 클래스에서 상속 되며 UserControl 사용자를 IContainerControl 위해를 구현 합니다.That class inherits from the UserControl class, and UserControl implements IContainerControl for you.

속성

ActiveControl ActiveControl ActiveControl ActiveControl

Container 컨트롤에 있는 활성 컨트롤을 가져오거나 설정합니다.Gets or sets the control that is active on the container control.

메서드

ActivateControl(Control) ActivateControl(Control) ActivateControl(Control) ActivateControl(Control)

지정된 컨트롤을 활성화합니다.Activates a specified control.

적용 대상

추가 정보