ControlAdapter.Control プロパティ

定義

このコントロール アダプターの割り当て先コントロールへの参照を取得します。

protected:
 property System::Web::UI::Control ^ Control { System::Web::UI::Control ^ get(); };
[System.ComponentModel.Browsable(false)]
protected System.Web.UI.Control Control { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Control : System.Web.UI.Control
Protected ReadOnly Property Control As Control

プロパティ値

Control の割り当て先である ControlAdapter

属性

次のコード例は、 クラスからカスタム コントロールを派生させ、 クラスから Control 継承する対応するアダプターを作成する方法を ControlAdapter 示しています。 アダプターは プロパティを Control オーバーライドし、コントロールへの厳密に型指定された参照を返します。

#using <System.Web.Mobile.dll>
#using <System.dll>
#using <System.Web.dll>

using namespace System;
using namespace System::Web::UI;
using namespace System::Web::UI::Adapters;
using namespace System::Web::UI::WebControls;

public ref class CustomControl: public Control{};

public ref class CustomControlAdapter: public ControlAdapter
{
public:

   property System::Web::UI::Control^ Control 
   {
      // Return a strongly-typed reference to your custom control.
      System::Web::UI::Control^ get()
      {
         return (CustomControl^)ControlAdapter::Control;
      }
   }
   // Override other ControlAdapter members, as necessary. 
};
using System;
using System.Web.UI;
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;

public class CustomControl : Control
{
    // Add your custom control code.
}

public class CustomControlAdapter : ControlAdapter
{
    // Return a strongly-typed reference to your custom control.
    public new CustomControl Control
    {
        get
        {
            return (CustomControl)base.Control;
        }

        // Override other ControlAdapter members, as necessary. 
    }
}
Imports System.Web.UI
Imports System.Web.UI.Adapters
Imports System.Web.UI.WebControls

Public Class CustomControl
    Inherits Control

    ' Add your custom control code.

End Class

Public Class CustomControlAdapter
    Inherits ControlAdapter

    ' Return a strongly-typed reference to your custom control.
    Public Shadows ReadOnly Property Control() As CustomControl
        Get
            Return CType(MyBase.Control, CustomControl)
        End Get
    End Property

    ' Override other ControlAdapter member as necessary. 

End Class

注釈

派生コントロール アダプターがコントロールにアタッチされている場合、.NET Frameworkはコントロール メンバーではなく特定のアダプター メンバーを呼び出します。

注意 (継承者)

クラスから ControlAdapter 継承する場合は、少なくとも、「例」セクションに示すように、コントロールの厳密に型指定されたインスタンスを返すプロパティを実装 Control する必要があります。

適用対象

こちらもご覧ください