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

DataGridDesigner クラス

DataGrid Web サーバー コントロールデザイン時の動作拡張します。

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

Public Class DataGridDesigner
    Inherits BaseDataListDesigner
Dim instance As DataGridDesigner
public class DataGridDesigner : BaseDataListDesigner
public ref class DataGridDesigner : public
 BaseDataListDesigner
public class DataGridDesigner extends BaseDataListDesigner
public class DataGridDesigner extends
 BaseDataListDesigner
使用例使用例

DataGridDesigner クラス拡張する方法次のコード例示します。このコードは、GetDesignTimeHtml メソッドオーバーライドして、DataGrid コントロールデザイン サーフェイス表示されるときに CellPadding、BorderWidth、および BorderColor の各プロパティカスタマイズます。

Imports System
Imports System.Diagnostics
Imports System.ComponentModel
Imports System.Drawing
Imports System.Web.UI.Design.WebControls
Imports System.Web.UI.WebControls

Namespace Examples.AspNet

    ' Create a designer class for the SimpleDataList class.
    <System.Security.Permissions.SecurityPermission( _
    System.Security.Permissions.SecurityAction.Demand, _
    Flags:=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)>
 _
    Public Class SimpleDataListDesigner
        Inherits DataListDesigner

        Private simpleList As SimpleDataList


        ' Override the GetDesignTimeHtml method to add style to the
 control
        ' on the design surface.
        Public Overrides Function
 GetDesignTimeHtml() As String
            ' Cast the control to the Component property of the designer.
            simpleList = CType(Component, SimpleDataList)

            Dim designTimeHtml As String
 = Nothing

            ' Create variables to hold current property values.
            Dim oldBorderWidth As Unit = simpleList.BorderWidth
            Dim oldBorderColor As Color = simpleList.BorderColor

            ' Set the properties and generate the design-time HTML.
            If (simpleList.Enabled) Then
                Try
                    simpleList.BorderWidth = Unit.Point(5)
                    simpleList.BorderColor = Color.Purple
                    designTimeHtml = MyBase.GetDesignTimeHtml()

                    ' Call the GetErrorDesignTimeHtml method if an
                    ' exception occurs.
                Catch ex As Exception
                    designTimeHtml = GetErrorDesignTimeHtml(ex)

                    ' Return the properties to their original settings.
                Finally
                    simpleList.BorderWidth = oldBorderWidth
                    simpleList.BorderColor = oldBorderColor
                End Try
                ' If the list is not enabled, call the GetEmptyDesignTimeHtml
                ' method.
            Else
                designTimeHtml = GetEmptyDesignTimeHtml()
            End If

            Return designTimeHtml

        End Function

        Protected Overrides Function
 GetEmptyDesignTimeHtml() As String
            Dim emptyText As String

            ' Check the CanEnterTemplateMode property to
            ' specify which text to display if ItemTemplate 
            ' does not contain a value.
            If CanEnterTemplateMode Then
                emptyText = _
                    "<b>Either the Enabled property value
 is false " + _
                    "or you need to set the ItemTemplate for this
 " + _
                    "control.<br>Right-click to edit templates.</b>"
            Else
                emptyText = _
                    "<b>You cannot edit templates in this
 view.<br>" + _
                    "Switch to HTML view to define the ItemTemplate.</b>"
            End If

            Return CreatePlaceHolderDesignTimeHtml(emptyText)
        End Function

        ' Generate HTML to indicate that an error has occurred.
        Protected Overrides Function
 GetErrorDesignTimeHtml(ByVal exc As _
            Exception) As String

            Return CreatePlaceHolderDesignTimeHtml( _
                "<b>An error occurred</b>.<br>Check
 to ensure that all " + _
                "properties are valid.")
        End Function


        ' Override the Initialize method to ensure that
        ' only an instance of the SimpleDataList class is
        ' used by this designer class.
        Public Overrides Sub
 Initialize(ByVal component As IComponent)
            simpleList = CType(component, SimpleDataList)

            If IsNothing(simpleList) Then
                Throw New ArgumentException("Must
 be a SimpleDataList.", "component")
            End If

            MyBase.Initialize(component)
        End Sub
    End Class
End Namespace

DesignerAttribute 属性使用してデザイナDataGrid コントロール関連付ける方法次の例に示します

' Override the Initialize method to ensure that
' only an instance of the SimpleDataList class is
' used by this designer class.
Public Overrides Sub Initialize(ByVal
 component As IComponent)
    simpleList = CType(component, SimpleDataList)

    If IsNothing(simpleList) Then
        Throw New ArgumentException("Must
 be a SimpleDataList.", "component")
    End If

    MyBase.Initialize(component)
End Sub
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.ComponentModel.Design.ComponentDesigner
     System.Web.UI.Design.HtmlControlDesigner
       System.Web.UI.Design.ControlDesigner
         System.Web.UI.Design.TemplatedControlDesigner
           System.Web.UI.Design.WebControls.BaseDataListDesigner
            System.Web.UI.Design.WebControls.DataGridDesigner
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「DataGridDesigner クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS