ButtonDesigner クラスとは? わかりやすく解説

ButtonDesigner クラス

Button Web サーバー コントロールを、ビジュアルなデザイナで、デザイン時に使用できるようにするために使用します

名前空間: System.Web.UI.Design.WebControls
アセンブリ: System.Design (system.design.dll 内)
構文構文

Public Class ButtonDesigner
    Inherits ControlDesigner
Dim instance As ButtonDesigner
public class ButtonDesigner : ControlDesigner
public ref class ButtonDesigner : public
 ControlDesigner
public class ButtonDesigner extends ControlDesigner
public class ButtonDesigner extends
 ControlDesigner
解説解説
使用例使用例

このセクションには、2 つコード例用意されています。最初コード例は、ButtonDesigner クラス拡張する方法示してます。2 番目のコード例は、Button クラス拡張して最初コード例作成したクラス関連付ける方法示してます。

ButtonDesigner クラス拡張して、GetDesignTimeHtml メソッドオーバーライドするカスタム デザイナ クラス作成する方法次のコード例示します。BorderStyle プロパティがまだ設定されていない (つまり、NotSet フィールド値がない) 場合GetDesignTimeHtml メソッド呼び出すと、このプロパティが幅 3 ピクセルの青い点線境界線設定され、その境界線デザイン サーフェイス表示されます。BorderStyle プロパティに値が既に設定されている場合は、既存境界線プロパティの値が表示されます。

通常GetDesignTimeHtml は、その基本メソッドである ControlDesigner.GetDesignTimeHtml を呼び出します。この基本メソッドは、関連付けられたコントロールの Control.RenderControl メソッド呼び出してマークアップ生成します

' Create a class that derives from ButtonDesigner
' and displays the custom SampleButton control
' on the design surface.
Imports System
Imports System.Web.UI.Design
Imports System.Drawing
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls

Namespace Examples.AspNet 

    
    Public Class SampleButtonDesigner
        Inherits ButtonDesigner

        ' Override the GetDesignTimeHtml method.
        Public Overrides Function
 GetDesignTimeHtml() As String

            Dim sampleButton As SampleButton
 = CType(Component, SampleButton)
            Dim designTimeHtml As String
 = Nothing

            ' Check the control's BorderStyle property
            ' to conditionally render design-time HTML.
            If (sampleButton.BorderStyle = BorderStyle.NotSet)
 Then

                ' Create variables to hold current property settings.
                Dim oldBorderStyle As BorderStyle
 = sampleButton.BorderStyle
                Dim oldBorderWidth As Unit
 = sampleButton.BorderWidth
                Dim oldBorderColor As Color
 = sampleButton.BorderColor

                ' Set properties and the design-time HTML.
                Try
                    sampleButton.BorderStyle = BorderStyle.Dashed
                    sampleButton.BorderWidth = Unit.Pixel(3)
                    sampleButton.BorderColor = Color.Blue
                    designTimeHtml = MyBase.GetDesignTimeHtml()

                    ' If an exception occurs, call the GetErrorDesignTimeHtml
                    ' method.
                Catch ex As Exception
                    designTimeHtml = GetErrorDesignTimeHtml(ex)

                    ' Return properties to their original settings.
                Finally
                    sampleButton.BorderStyle = oldBorderStyle
                    sampleButton.BorderWidth = oldBorderWidth
                    sampleButton.BorderColor = oldBorderColor
                End Try

            Else
                designTimeHtml = MyBase.GetDesignTimeHtml()
            End If

            Return designTimeHtml

        End Function

    End Class
End Namespace

Button クラス拡張し上記の例で作成した SampleButtonDesigner クラスに DesignerAttribute オブジェクト使用して関連付ける単純なクラス使用方法次のコード例示します

<DesignerAttribute( _
    GetType(Examples.AspNet.SampleButtonDesigner))> _
Public Class SampleButton
    Inherits Button
    ' Include code here for a custom 
    ' class that inherits from Button.        
End Class
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.ComponentModel.Design.ComponentDesigner
     System.Web.UI.Design.HtmlControlDesigner
       System.Web.UI.Design.ControlDesigner
        System.Web.UI.Design.WebControls.ButtonDesigner
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からButtonDesigner クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からButtonDesigner クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からButtonDesigner クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ButtonDesigner クラス」の関連用語

ButtonDesigner クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ButtonDesigner クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS