ContainerControl.ActiveControl プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ContainerControl.ActiveControl プロパティの意味・解説 

ContainerControl.ActiveControl プロパティ

コンテナ コントロール上のアクティブ コントロール取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As ContainerControl
Dim value As Control

value = instance.ActiveControl

instance.ActiveControl = value
public Control ActiveControl { get; set;
 }
/** @property */
public final Control get_ActiveControl ()

/** @property */
public final void set_ActiveControl (Control
 value)

プロパティ
ContainerControl で現在アクティブControl

例外例外
解説解説
使用例使用例

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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ContainerControl.ActiveControl プロパティ」の関連用語

ContainerControl.ActiveControl プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ContainerControl.ActiveControl プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS