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

DetailsViewDesigner クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

DetailsView コントロールを、ビジュアル デザイナで、デザイン時に使用できるようにします。

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

Public Class DetailsViewDesigner
    Inherits DataBoundControlDesigner
Dim instance As DetailsViewDesigner
public class DetailsViewDesigner : DataBoundControlDesigner
public ref class DetailsViewDesigner : public
 DataBoundControlDesigner
public class DetailsViewDesigner extends DataBoundControlDesigner
public class DetailsViewDesigner extends
 DataBoundControlDesigner
解説解説

ビジュアル デザイナソース ビューからデザイン ビュー切り替えると、DetailsView コントロール記述するマークアップ ソース コード解析されコントロールデザインバージョンデザイン サーフェイス作成されます。元のソース ビュー切り替えると、デザイン時のコントロールマークアップソース コード保持されWeb ページマークアップ反映されます。

DetailsViewDesigner クラスプロパティは、次の機能提供します

DetailsViewDesigner クラスメソッドは、次の機能提供します

DetailsView コントロールでは、デザイン時の編集可能領域サポートされていないため、GetEditableDesignerRegionContent メソッドと SetEditableDesignerRegionContent メソッド何の機能提供しません。

使用例使用例

DetailsViewDesigner クラス拡張しDetailsView コントロールか派生したコントロール外観デザイン時に変更するコード例次に示します

この例では、MyDetailsView コントロールDetailsView から派生させています。MyDetailsView は、単に DetailsView コントロールコピーです。また、この例では、DetailsViewDesigner から MyDetailsViewDesigner クラス派生させ、MyDetailsViewDesigner の DesignerAttribute オブジェクトMyDetailsView コントロール配置してます。

The MyDetailsViewDesigner は、SampleRowCount プロパティオーバーライドして、MyDetailsViewデザインビューページ行に 5 つページ リンクが含まれることを指定しますまた、PreFilterProperties メソッドオーバーライドして、デザイン時に [Property] グリッドNamingContainer プロパティ表示します。さらに、GetDesignTimeHtml メソッドオーバーライドして、Caption プロパティ指定されている場合は、デザイン時の MyDetailsView グリッド新し先頭行としてこのプロパティ挿入しますMyDetailsView の BorderStyle プロパティの値が NotSet または None の場合GetDesignTimeHtml は、コントロール周囲に青い点線境界線描画して、コントロール範囲わかりやすくます。

Imports System
Imports System.Web
Imports System.Drawing
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports System.Collections
Imports System.ComponentModel
Imports System.Security.Permissions

Namespace Examples.VB.WebControls.Design

    ' The MyDetailsView is a copy of the DetailsView.
    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <Designer(GetType(Examples.VB.WebControls.Design.MyDetailsViewDesigner))>
 _
    Public Class MyDetailsView
        Inherits DetailsView
    End Class ' MyVBDetailsView

    ' Override members of the DetailsViewDesigner.
    <ReflectionPermission(SecurityAction.Demand, Flags:=ReflectionPermissionFlag.MemberAccess)>
 _
    Public Class MyDetailsViewDesigner
        Inherits DetailsViewDesigner

        ' Determines the number of page links in the pager row
        ' when viewed in the designer.
        Protected Overrides ReadOnly
 Property SampleRowCount() As Integer
            Get
                ' Render five page links in the pager row.
                Return 5
            End Get
        End Property ' SampleRowCount

        ' Shadow the control properties with design-time properties.
        Protected Overrides Sub
 PreFilterProperties( _
            ByVal properties As IDictionary)

            ' Call the base method first.
            MyBase.PreFilterProperties(properties)

            ' Make the NamingContainer visible in the Properties grid.
            Dim selectProp As PropertyDescriptor
 = _
                CType(properties("NamingContainer"),
 PropertyDescriptor)
            properties("NamingContainer") = _
                TypeDescriptor.CreateProperty(selectProp.ComponentType, _
                    selectProp, BrowsableAttribute.Yes)
        End Sub ' PreFilterProperties

        ' Generate the design-time markup.
        Private Const capTag As
 String = "caption"
        Private Const trOpen As
 String = "tr><td colspan=2 align=center"
        Private Const trClose As
 String = "td></tr"

        Public Overrides Function
 GetDesignTimeHtml() As String

            ' Make the full extent of the control more visible in the
 designer.
            ' If the border style is None or NotSet, change the border
 to
            ' a wide, blue, dashed line. Include the caption within
 the border.
            Dim myDV As MyDetailsView = CType(Component,
 MyDetailsView)
            Dim markup As String
 = Nothing
            Dim charX As Integer

            ' Check if the border style should be changed.
            If (myDV.BorderStyle = BorderStyle.NotSet Or
 _
                myDV.BorderStyle = BorderStyle.None) Then

                Dim oldBorderStyle As BorderStyle
 = myDV.BorderStyle
                Dim oldBorderWidth As Unit
 = myDV.BorderWidth
                Dim oldBorderColor As Color
 = myDV.BorderColor

                ' Set design-time properties and catch any exceptions.
                Try
                    myDV.BorderStyle = BorderStyle.Dashed
                    myDV.BorderWidth = Unit.Pixel(3)
                    myDV.BorderColor = Color.Blue

                    ' Call the base method to generate the markup.
                    markup = MyBase.GetDesignTimeHtml()

                Catch ex As Exception
                    markup = GetErrorDesignTimeHtml(ex)

                Finally
                    ' Restore the properties to their original settings.
                    myDV.BorderStyle = oldBorderStyle
                    myDV.BorderWidth = oldBorderWidth
                    myDV.BorderColor = oldBorderColor
                End Try

            Else
                ' Call the base method to generate the markup.
                markup = MyBase.GetDesignTimeHtml()
            End If

            ' Look for a <caption> tag.
            charX = markup.IndexOf(capTag)
            If charX > 0 Then

                ' Replace the first caption with 
                ' "tr><td colspan=2 align=center".
                markup = markup.Remove(charX, _
                    capTag.Length).Insert(charX, trOpen)

                ' Replace the second caption with "td></tr".
                charX = markup.IndexOf(capTag, charX)
                If charX > 0 Then
                    markup = markup.Remove(charX, _
                        capTag.Length).Insert(charX, trClose)
                End If
            End If

            Return markup

        End Function ' GetDesignTimeHtml
    End Class ' MyDetailsViewDesigner
End Namespace ' Examples.VB.WebControls.Design
using System;
using System.Web;
using System.Drawing;
using System.Web.UI.WebControls;
using System.Web.UI.Design.WebControls;
using System.Collections;
using System.ComponentModel;
using System.Security.Permissions;

namespace Examples.CS.WebControls.Design
{
    // The MyDetailsView is a copy of the DetailsView.
    [AspNetHostingPermission(SecurityAction.Demand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    [Designer(typeof(Examples.CS.WebControls.Design.MyDetailsViewDesigner))]
    public class MyDetailsView : DetailsView
    {
    } // MyDetailsView

    // Override members of the DetailsViewDesigner.
    [ReflectionPermission(SecurityAction.Demand, Flags=ReflectionPermissionFlag.MemberAccess)]
    public class MyDetailsViewDesigner : DetailsViewDesigner
    {
        // Determines the number of page links in the pager row
        // when viewed in the designer.
        protected override int SampleRowCount
        {
            get
            {
                // Render five page links in the pager row.
                return 5;
            }
        } // SampleRowCount

        // Shadow the control properties with design-time properties.
        protected override void PreFilterProperties(IDictionary
 properties)
        {
            // Call the base method first.
            base.PreFilterProperties(properties);

            // Make the NamingContainer visible in the Properties grid.
            PropertyDescriptor selectProp = 
                (PropertyDescriptor)properties["NamingContainer"];
            properties["NamingContainer"] =
                TypeDescriptor.CreateProperty(selectProp.ComponentType, 
                    selectProp, BrowsableAttribute.Yes);
        } // PreFilterProperties

        // Generate the design-time markup.
        const string capTag = "caption";
        const string trOpen = "tr><td
 colspan=2 align=center";
        const string trClose = "td></tr";

        public override string GetDesignTimeHtml()
        {
            // Make the full extent of the control more visible in the
 designer.
            // If the border style is None or NotSet, change the border
 to
            // a wide, blue, dashed line. Include the caption within
 the border.
            MyDetailsView myDV = (MyDetailsView)Component;
            string markup = null;
            int charX;

            // Check if the border style should be changed.
            if (myDV.BorderStyle == BorderStyle.NotSet ||
                myDV.BorderStyle == BorderStyle.None)
            {
                BorderStyle oldBorderStyle = myDV.BorderStyle;
                Unit oldBorderWidth = myDV.BorderWidth;
                Color oldBorderColor = myDV.BorderColor;

                // Set design-time properties and catch any exceptions.
                try
                {
                    myDV.BorderStyle = BorderStyle.Dashed;
                    myDV.BorderWidth = Unit.Pixel(3);
                    myDV.BorderColor = Color.Blue;

                    // Call the base method to generate the markup.
                    markup = base.GetDesignTimeHtml();
                }
                catch (Exception ex)
                {
                    markup = GetErrorDesignTimeHtml(ex);
                }
                finally
                {
                    // Restore the properties to their original settings.
                    myDV.BorderStyle = oldBorderStyle;
                    myDV.BorderWidth = oldBorderWidth;
                    myDV.BorderColor = oldBorderColor;
                }
            }
            else
                // Call the base method to generate the markup.
                markup = base.GetDesignTimeHtml();

            // Look for a <caption> tag.
            if ((charX = markup.IndexOf(capTag)) > 0)
            {
                // Replace the first caption with 
                // "tr><td colspan=2 align=center".
                markup = markup.Remove(charX,
                    capTag.Length).Insert(charX, trOpen);

                // Replace the second caption with "td></tr".
                if ((charX = markup.IndexOf(capTag, charX)) >
 0)
                    markup = markup.Remove(charX,
                        capTag.Length).Insert(charX, trClose); 
            }
            return markup;

        } // GetDesignTimeHtml
    } // MyDetailsViewDesigner
} // Examples.CS.WebControls.Design
継承階層継承階層
System.Object
   System.ComponentModel.Design.ComponentDesigner
     System.Web.UI.Design.HtmlControlDesigner
       System.Web.UI.Design.ControlDesigner
         System.Web.UI.Design.WebControls.BaseDataBoundControlDesigner
           System.Web.UI.Design.WebControls.DataBoundControlDesigner
            System.Web.UI.Design.WebControls.DetailsViewDesigner
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「DetailsViewDesigner クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS