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

Public Class MenuDesigner Inherits HierarchicalDataBoundControlDesigner Implements IDataBindingSchemaProvider
public ref class MenuDesigner : public HierarchicalDataBoundControlDesigner, IDataBindingSchemaProvider

Menu クラスは、階層構造のメニューに Web サーバー コントロールを提供します。
ビジュアルなデザイナで、ソース ビューからデザイン ビューに切り替えると、関連付けられた Menu コントロールを記述するマークアップのソース コードが解析され、コントロールのデザイン時バージョンがデザイン サーフェイスに作成されます。元のソース ビューに切り替えると、デザイン時のコントロールがマークアップに保持され、Web ページの既存のマークアップに追加されます。MenuDesigner クラスは、ビジュアルなデザイナで、Menu コントロールをデザイン時に使用できるようにします。
ActionLists プロパティは、DesignerActionListCollection オブジェクトを返します。一般にこのオブジェクトには、デザイナの継承ツリーの各レベルについて、DesignerActionList クラスから派生したオブジェクトが格納されます。AutoFormats プロパティは、[オートフォーマット] ダイアログ ボックスで表示するための書式指定スキームのコレクションを返します。
TemplateGroups プロパティは、関連付けられた Menu コントロールのテンプレートについて、テンプレート グループのコレクションを返します。UsePreviewControl プロパティは、常に true を返します。デザイナは、関連付けられた Menu の一時的なコピーを作成して、デザイン時のマークアップを生成します。
MenuDesigner クラスのメソッドは、次の機能を提供します。
-
Initialize メソッドは、関連付けられた Menu コントロールをデザイナで表示、編集、デザインできるように準備します。GetDesignTimeHtml メソッドは、デザイン時に、関連付けられた Menu のレンダリングに使用するマークアップを返します。
-
GetEmptyDesignTimeHtml メソッドは、マークアップを別の方法で使用できない場合に、関連付けられたコントロールのプレースホルダをデザイン時に表示するためのマークアップを取得します。GetErrorDesignTimeHtml メソッドは、エラーが発生した場合に、関連付けられたコントロールをデザイン時表示するマークアップを提供します。
-
DataBind メソッドは、関連付けられた Menu コントロールをデザイン時のデータ ソースにバインドします。GetSampleDataSource メソッドは、デザイン時に、関連付けられたコントロールに使用できるサンプル データ ソースを構築します。

MenuDesigner クラスを拡張し、Menu コントロールから派生したコントロールの外観をデザイン時に変更するコード例を次に示します。
この例では、MyMenu クラスを Menu から派生させています。MyMenu クラスは、Menu のコピーです。また、この例では、MenuDesigner クラスから MyMenuDesigner クラスを派生し、MyMenu クラスの MyMenuDesigner に DesignerAttribute 属性を適用しています。
The MyMenuDesigner は、次の MenuDesigner のメンバをオーバーライドします。
-
コントロールの範囲がよりわかりやすくなるように、コントロールの周囲にオレンジ色の点線の境界線を描画する GetDesignTimeHtml メソッド。
-
赤の太字で表示されるエラー メッセージを含んだプレースホルダのマークアップを生成する GetErrorDesignTimeHtml メソッド。
-
メニュー項目が定義されていないことを示すメッセージを含んだプレースホルダのマークアップを生成する GetEmptyDesignTimeHtml。
-
関連付けられたコントロールが MyMenu オブジェクトではない場合に ArgumentException 例外をスローする Initialize メソッド。
Imports System Imports System.Web Imports System.Web.UI.WebControls Imports System.Web.UI.Design.WebControls Imports System.ComponentModel Imports System.Security.Permissions Imports System.Drawing Namespace Examples.VB.WebControls.Design ' The MyMenu is a copy of the Menu. <AspNetHostingPermission(SecurityAction.Demand, _ Level:=AspNetHostingPermissionLevel.Minimal)> _ <AspNetHostingPermission(SecurityAction.InheritanceDemand, _ Level:=AspNetHostingPermissionLevel.Minimal)> _ <Designer(GetType(Examples.VB.WebControls.Design.MyMenuDesigner))> _ Public Class MyMenu Inherits Menu End Class ' MyMenu ' Override members of the MenuDesigner. Public Class MyMenuDesigner Inherits MenuDesigner ' Generate the design-time markup for the control when an error occurs. Protected Overrides Function GetErrorDesignTimeHtml( _ ByVal ex As Exception) As String ' Write the error message text in red, bold. Dim errorRendering As String = _ "<span style=""font-weight:bold; color:Red; "">" & _ ex.Message & "</span>" Return CreatePlaceHolderDesignTimeHtml(errorRendering) End Function ' GetErrorDesignTimeHtml ' Generate the design-time markup for the control ' when the template is empty. Protected Overrides Function GetEmptyDesignTimeHtml() As String Dim noElements As String = "Contains no menu items." Return CreatePlaceHolderDesignTimeHtml(noElements) End Function ' GetEmptyDesignTimeHtml ' 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 an orange dotted line. Dim myMenuCtl As MyMenu = CType(ViewControl, MyMenu) Dim markup As String = Nothing ' Check if the border style should be changed. If (myMenuCtl.BorderStyle = BorderStyle.NotSet Or _ myMenuCtl.BorderStyle = BorderStyle.None) Then Dim oldBorderStyle As BorderStyle = myMenuCtl.BorderStyle Dim oldBorderColor As Color = myMenuCtl.BorderColor ' Set the design-time properties and catch any exceptions. Try myMenuCtl.BorderStyle = BorderStyle.Dotted myMenuCtl.BorderColor = Color.FromArgb(&HFF7F00) ' 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. myMenuCtl.BorderStyle = oldBorderStyle myMenuCtl.BorderColor = oldBorderColor End Try Else ' Call the base method to generate the markup. markup = MyBase.GetDesignTimeHtml() End If Return markup End Function ' GetDesignTimeHtml Public Overrides Sub Initialize(ByVal component As IComponent) ' Ensure that only a MyMenu can be created in this designer. If Not TypeOf component Is MyMenu Then Throw New ArgumentException( _ "The component is not a MyMenu control.") End If MyBase.Initialize(component) End Sub ' Initialize End Class ' MyMenuDesigner 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; using System.Drawing; namespace Examples.CS.WebControls.Design { // The MyMenu is a copy of the Menu. [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [Designer(typeof(Examples.CS.WebControls.Design.MyMenuDesigner))] public class MyMenu : Menu { } // MyMenu // Override members of the MenuDesigner. public class MyMenuDesigner : MenuDesigner { // Generate the design-time markup for the control when an error occurs. protected override string GetErrorDesignTimeHtml(Exception ex) { // Write the error message text in red, bold. string errorRendering = "<span style=\"font-weight:bold; color:Red; \">" + ex.Message + "</span>"; return CreatePlaceHolderDesignTimeHtml(errorRendering); } // GetErrorDesignTimeHtml // Generate the design-time markup for the control // when the template is empty. protected override string GetEmptyDesignTimeHtml() { string noElements = "Contains no menu items."; return CreatePlaceHolderDesignTimeHtml(noElements); } // GetEmptyDesignTimeHtml // 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 an orange dotted line. MyMenu myMenuCtl = (MyMenu)ViewControl; string markup = null; // Check if the border style should be changed. if (myMenuCtl.BorderStyle == BorderStyle.NotSet || myMenuCtl.BorderStyle == BorderStyle.None) { BorderStyle oldBorderStyle = myMenuCtl.BorderStyle; Color oldBorderColor = myMenuCtl.BorderColor; // Set the design-time properties and catch any exceptions. try { myMenuCtl.BorderStyle = BorderStyle.Dotted; myMenuCtl.BorderColor = Color.FromArgb(0xFF7F00); // 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. myMenuCtl.BorderStyle = oldBorderStyle; myMenuCtl.BorderColor = oldBorderColor; } } else // Call the base method to generate the markup. markup = base.GetDesignTimeHtml(); return markup; } // GetDesignTimeHtml public override void Initialize(IComponent component) { // Ensure that only a MyMenu can be created in this designer. if (!(component is MyMenu)) throw new ArgumentException( "The component is not a MyMenu control."); base.Initialize(component); } // Initialize } // MyMenuDesigner } // Examples.CS.WebControls.Design

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.HierarchicalDataBoundControlDesigner
System.Web.UI.Design.WebControls.MenuDesigner


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に収録されているすべての辞書からMenuDesigner クラスを検索する場合は、下記のリンクをクリックしてください。

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