Style.RegisterStyle(String, Type, Object, Boolean) メソッド

定義

スタイル プロパティを登録して、参照用の一意なキーを返します。 この API は、互換性のために残されています。 ASP.NET モバイル アプリケーションを開発する方法については、「ASP.NET を使用した Mobile Apps & サイト」を参照してください。

public:
 static System::Object ^ RegisterStyle(System::String ^ name, Type ^ type, System::Object ^ defaultValue, bool inherit);
public static object RegisterStyle (string name, Type type, object defaultValue, bool inherit);
static member RegisterStyle : string * Type * obj * bool -> obj
Public Shared Function RegisterStyle (name As String, type As Type, defaultValue As Object, inherit As Boolean) As Object

パラメーター

name
String

スタイル プロパティの名前。

type
Type

プロパティに使用する型。

defaultValue
Object

プロパティの既定値です。

inherit
Boolean

親オブジェクトからスタイルを継承するかどうかを示します。 既定値は、true です。

戻り値

検索用の一意キー。

次の例では、 メソッドを RegisterStyle 使用して、継承をサポートし、既定値が空の文字列 ("") である文字列プロパティを登録する方法を示します。 この不完全な例には、基底クラスの既定のインデクサー プロパティを使用してこのプロパティの要素にアクセスするパブリック プロパティが含まれています。

public class CustomStyle : 
    System.Web.UI.MobileControls.Style
    {
        private string themeNameKey;

        public CustomStyle(string name)
        {
            themeNameKey = 
                RegisterStyle(name, typeof(String), 
                    String.Empty, true).ToString();
        }
        
        public string ThemeName
        {
            get
            {
                return this[themeNameKey].ToString();
            }
            set
            {
                this[themeNameKey] = value;
            }
        }
    }
Public Class CustomStyle
    Inherits System.Web.UI.MobileControls.Style
    Private themeNameKey As String

    Public Sub New(ByVal name As String)
        themeNameKey = _
            RegisterStyle(name, GetType(String), _
                String.Empty, True).ToString()
    End Sub
    
    Public Property ThemeName() As String
        Get
            Return Me(themeNameKey).ToString()
        End Get
        Set(ByVal value As String)
            Me(themeNameKey) = value
        End Set
    End Property
End Class

注釈

継承されたスタイル クラスからのみ呼び出されます。

適用対象

こちらもご覧ください