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

LabelDesigner クラス

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

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

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

Label コントロールかSampleLabel コントロール派生させ、DesignerAttribute 属性SampleLabel コントロール適用して SampleLabelDesigner クラス関連付ける方法次のコード例示します

また、このコード例では、LabelDesigner クラスから SampleLabelDesigner派生させています。最初の BorderStyle の値が NotSet または None だった場合は、GetDesignTimeHtml メソッドオーバーライドして BorderStyle プロパティを Dashed に設定してます。これにより、関連付けられたコントロールデザイン時にわかりやすく表示されます。

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

Namespace Examples.VB.WebControls.Design

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

    ' Override members of the LabelDesigner.
    Public Class SampleLabelDesigner
        Inherits LabelDesigner

        ' Generate the design-time markup.
        Public Overrides Function
 GetDesignTimeHtml() As String

            ' Make the control more visible in the designer.  If the
 border 
            ' style is None or NotSet, change the border to a dashed
 line. 
            Dim sampleLabel As SampleLabel
 = CType(Component, SampleLabel)
            Dim designTimeMarkup As String
 = Nothing

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

                Dim oldBorderStyle As BorderStyle
 = sampleLabel.BorderStyle

                Try
                    ' Set the design-time BorderStyle.
                    sampleLabel.BorderStyle = BorderStyle.Dashed

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

                Catch ex As Exception
                    ' If an exception occurs, generate an error message.
                    designTimeMarkup = GetErrorDesignTimeHtml(ex)

                Finally
                    ' Restore the BorderStyle to its original setting.
                    sampleLabel.BorderStyle = oldBorderStyle
                End Try

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

            Return designTimeMarkup
        End Function ' GetDesignTimeHtml
    End Class ' SampleLabelDesigner
End Namespace ' Examples.VB.WebControls.Design
using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.Design.WebControls;
using System.ComponentModel;
using System.Security.Permissions;

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

    // Override members of the LabelDesigner.
    public class SampleLabelDesigner : LabelDesigner
    {
        // Generate the design-time markup.
        public override string GetDesignTimeHtml()
        {
            // Make the control more visible in the designer.  If the
 border 
            // style is None or NotSet, change the border to a dashed
 line. 
            SampleLabel sampleLabel = (SampleLabel)Component;
            string designTimeMarkup = null;

            // Check if the border style should be changed.
            if (sampleLabel.BorderStyle == BorderStyle.NotSet
 ||
                sampleLabel.BorderStyle == BorderStyle.None)
            {
                BorderStyle oldBorderStyle = sampleLabel.BorderStyle;

                try
                {
                    // Set the design-time BorderStyle.
                    sampleLabel.BorderStyle = BorderStyle.Dashed;

                    // Call the base method to generate the markup.
                    designTimeMarkup = base.GetDesignTimeHtml();
                }
                catch (Exception ex)
                {
                    // If an exception occurs, generate an error message.
                    designTimeMarkup = GetErrorDesignTimeHtml(ex);
                }
                finally
                {
                    // Restore the BorderStyle to its original setting.
                    sampleLabel.BorderStyle = oldBorderStyle;
                }
            }
            else
                // Call the base method to generate the markup.
                designTimeMarkup = base.GetDesignTimeHtml();

            return designTimeMarkup;
        } // GetDesignTimeHtml
    } // SampleLabelDesigner
} // Examples.CS.WebControls.Design
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.ComponentModel.Design.ComponentDesigner
     System.Web.UI.Design.HtmlControlDesigner
       System.Web.UI.Design.ControlDesigner
         System.Web.UI.Design.TextControlDesigner
          System.Web.UI.Design.WebControls.LabelDesigner
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
LabelDesigner メンバ
System.Web.UI.Design.WebControls 名前空間
Label
WebControl
BorderStyle
TextControlDesigner クラス
ControlDesigner クラス
HtmlControlDesigner クラス
ComponentDesigner
その他の技術情報
ASP.NET コントロール デザイナ概要
チュートリアル : Web サーバー コントロール用の基本的なコントロール デザイナ作成


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

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

辞書ショートカット

すべての辞書の索引

「LabelDesigner クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS