次の方法で共有


ReadWriteControlDesigner.MapPropertyToStyle メソッド

説明と値を含むプロパティを組み込み HTML スタイルに割り当てます。

Protected Overridable Sub MapPropertyToStyle( _
   ByVal propName As String, _   ByVal varPropValue As Object _)
[C#]
protected virtual void MapPropertyToStyle(stringpropName,objectvarPropValue);
[C++]
protected: virtual void MapPropertyToStyle(String* propName,Object* varPropValue);
[JScript]
protected function MapPropertyToStyle(
   propName : String,varPropValue : Object);

パラメータ

  • propName
    HTML スタイル属性に変換するプロパティ。
  • varPropValue
    変換するプロパティの値。

解説

Notes to Inheritors[note] デザイナを実装するには、このメソッドを派生クラスでオーバーライドする必要があります。

使用例

[Visual Basic] カスタム Panel クラスのプロパティの名前と値をチェックするコード例を次に示します。このコードは、プロパティ名が Wrap の場合、プロパティを HTML の NoWrap 属性にマッピングします。

 
' Override the MapPropertyToStyle method to set the
' Panel.Wrap property to the NoWrap HTML attribute.
Overrides Protected Sub MapPropertyToStyle(propName As String, varPropValue As Object) 
   ' Display messages when debugging.
   Debug.Assert(Not (propName = Nothing Or propName.Length <> 0), "Invalid property name passed in.")
   Debug.Assert(Not (varPropValue = Nothing), "Invalid property value passed in.")

   ' If the parameters passed to the method are null,
   ' return nothing. 
   If ((propName Is Nothing) And (varPropValue Is Nothing)) Then
      Return
   End If
   
   ' If the second parameter is not a null
   ' value, check whether the property name is Wrap.
   If Not (varPropValue Is Nothing) Then
      Try
         ' If property name is wrap, convert
         ' it to the HTML NoWrap attribute.
         If (propName.Equals("Wrap")) Then
            Dim strValue As String = String.Empty
            
            If (CType(varPropValue, Boolean)) Then
               Behavior.SetStyleAttribute("NoWrap", True, strValue, True)
            End If
         Else
           MyBase.MapPropertyToStyle(propName, varPropValue)             
         End If  
       Catch ex As Exception
         Debug.Fail(ex.ToString())
       End Try            
    End If
 End Sub 'MapPropertyToStyle

[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

ReadWriteControlDesigner クラス | ReadWriteControlDesigner メンバ | System.Web.UI.Design 名前空間