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


Label コントロールは、プログラムを使用して Web ページにテキストを表示できるようにします。
ビジュアルなデザイナでソース ビューからデザイン ビューに切り替えると、Label コントロールを記述するマークアップのソース コードが解析され、コントロールのデザイン時バージョンがデザイン サーフェイスに作成されます。元のソース ビューに切り替えると、デザイン時コントロールがマークアップのソース コードに永続化され、Web ページのマークアップに反映されます。LabelDesigner クラスは、Label コントロールをデザイン時に使用できるようにします。
OnComponentChanged メソッドは、関連付けられた Label コントロールに変更があったときに呼び出されます。

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

- SecurityPermission (アンマネージ コードを呼び出すために必要なアクセス許可)。要求値 : Demand。アクセス許可値 : UnmanagedCode。

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


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からLabelDesigner クラスを検索する場合は、下記のリンクをクリックしてください。

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