CheckBoxDesigner クラス
アセンブリ: System.Design (system.design.dll 内)


CheckBoxDesigner クラスは、ControlDesigner クラスの GetDesignTimeHtml メソッドをオーバーライドして、デザイン時にコントロールがわかりやすく表示されるようにします。Text プロパティが空の場合、このクラスの GetDesignTimeHtml メソッドは、コントロールの Text プロパティを、そのコントロールの Control.ID プロパティに設定します。

SampleCheckBoxDesigner という名前のカスタム デザイナ クラスを CheckBoxDesigner クラスから継承して作成するコード例を次に示します。このカスタム クラスは GetDesignTimeHtml メソッドをオーバーライドします。CheckBox.Text プロパティが設定済みでない場合は、このメソッドを呼び出すと、プロパティに文字列が設定され、デザイン サーフェイスにその文字列が表示されます。Text プロパティに値が既に設定されている場合は、その値が表示されます。
Imports System 'Imports System.Design Imports System.Drawing Imports System.ComponentModel Imports System.Web.UI.WebControls Imports System.Web.UI.Design Imports System.Web.UI.Design.WebControls 'Imports Examples.AspNet Namespace Examples.AspNet '.Design ' Create a class, named SampleCheckBoxDesigner, that overrides the ' GetDesignTimeHtml method to display the control on the design ' surface. Public Class SampleCheckBoxDesigner Inherits System.Web.UI.Design.WebControls.CheckBoxDesigner ' Override the GetDesignTimeHtml method to display a border on the ' control if the BorderStyle property has not been set by the user. Public Overrides Function GetDesignTimeHtml() As String Dim sampleCheckBox As SampleCheckBox = CType(Component, _ SampleCheckBox) Dim designTimeHtml As String = Nothing ' Check the control's BorderStyle property. If (sampleCheckBox.BorderStyle = BorderStyle.NotSet) Then ' Save the current value of the BorderStyle property. Dim oldBorderStyle As BorderStyle = _ sampleCheckBox.BorderStyle ' Change the value of the BorderStyle property and ' generate the design-time HTML. Try sampleCheckBox.BorderStyle = BorderStyle.Groove designTimeHtml = MyBase.GetDesignTimeHtml() ' If an exception occurs, call the GetErrorDesignTimeHtml ' method. Catch ex As Exception designTimeHtml = GetErrorDesignTimeHtml(ex) ' Restore the BorderStyle property to its original value. Finally sampleCheckBox.BorderStyle = oldBorderStyle End Try Else designTimeHtml = MyBase.GetDesignTimeHtml() End If Return designTimeHtml End Function End Class End Namespace
SampleCheckBox という名前の単純なクラスを CheckBox クラスから継承して作成するコード例を次に示します。このクラスは、DesignerAttribute クラスにより SampleCheckBoxDesigner クラスと関連付けられます。

System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.WebControls.CheckBoxDesigner


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CheckBoxDesigner クラスのページへのリンク