読み取り/書き込みサーバー コントロールのデザイン時動作を拡張します。
この型のすべてのメンバの一覧については、ReadWriteControlDesigner メンバ を参照してください。
System.Object
System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.ReadWriteControlDesigner
System.Web.UI.Design.WebControls.PanelDesigner
Public Class ReadWriteControlDesigner
Inherits ControlDesigner
[C#]
public class ReadWriteControlDesigner : ControlDesigner
[C++]
public __gc class ReadWriteControlDesigner : public ControlDesigner
[JScript]
public class ReadWriteControlDesigner extends ControlDesigner
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
このコントロール デザイナには、このデザイナのコントロールにコントロールをドロップする機能があります。
実装時の注意: コントロールへの子コントロールの追加をサポートするコントロールを持つデザイナを実装する場合は、 ReadWriteControlDesigner クラスを使用する必要があります。コントロールが子コントロールをサポートしないようにする場合は、 ControlDesigner クラスから派生したデザイナを使用します。
使用例
[Visual Basic] PanelDesigner クラスから派生した CustomPanelDesigner クラスのコード例を次に示します。このコードは、 MapPropertyToStyle メソッドに渡されたパラメータの値を確認し、パネルに対応しているかどうかをチェックします。 System.Web.UI.Panel.Wrap プロパティとその値は、HTML の NoWrap 属性にマッピングされます。
[Visual Basic] PanelDesigner クラスは、 ReadWriteControlDesigner クラスから直接派生したクラスです。したがって、 ReadWriteControlDesigner を直接オーバーライドすることによっても、同様のプロパティ マッピングを実装することはできます。ただし、 PanelDesigner.MapPropertyToStyle メソッドが提供する基本処理は実行されなくなります。
' Create a class that derives from the PanelDesigner
' class. Because PanelDesigner derives directly
' from ReadWriteControlDesigner, you could derive
' from the latter to accomplish the same design-
' time functionality found in this example.
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Drawing.Design
Imports Microsoft.Win32
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Namespace AspNet.Samples.Design
' The CustomPanelDesigner class is designed to be
' attached to a class that inherits the System.Web.UI.
' Panel class.
Public Class CustomPanelDesigner
Inherits PanelDesigner
' 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
' Override the OnBehaviorAttached method to call
' the MapPropertyToStyle method when the designer
' control's wrap property is set to true.
Overrides Protected Sub OnBehaviorAttached()
MyBase.OnBehaviorAttached()
Dim component As IComponent
Dim panel As CustomPanel = CType(component, CustomPanel)
Dim wrap As Boolean = panel.Wrap
If wrap Then
MapPropertyToStyle("Wrap", wrap)
End If
End Sub 'OnBehaviorAttached
End Class
End Namespace
[Visual Basic] 前述の例で示した CustomPanelDesigner クラスに関連付けられた、CustomPanel という名前のカスタム Panel クラスのコード例を次に示します。
' Create the class that uses the
' CustomPanelDesigner class to be
' displayed at design time.
<Designer(GetType( _
AspNet.Samples.Design.CustomPanelDesigner))> _
Public Class CustomPanel
Inherits System.Web.UI.WebControls.Panel
Overrides Public Property Wrap As Boolean
Get
Return MyBase.Wrap
End Get
Set
MyBase.Wrap = value
End Set
End Property
End Class
[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Web.UI.Design
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Design (System.Design.dll 内)