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

MenuDesigner クラス

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

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

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

Public Class MenuDesigner
    Inherits HierarchicalDataBoundControlDesigner
    Implements IDataBindingSchemaProvider
public class MenuDesigner : HierarchicalDataBoundControlDesigner,
 IDataBindingSchemaProvider
public ref class MenuDesigner : public
 HierarchicalDataBoundControlDesigner, IDataBindingSchemaProvider
public class MenuDesigner extends HierarchicalDataBoundControlDesigner
 implements IDataBindingSchemaProvider
public class MenuDesigner extends
 HierarchicalDataBoundControlDesigner implements IDataBindingSchemaProvider
解説解説

Menu クラスは、階層構造メニューWeb サーバー コントロール提供します

ビジュアルなデザイナで、ソース ビューからデザイン ビュー切り替えると、関連付けられた Menu コントロール記述するマークアップソース コード解析されコントロールデザインバージョンデザイン サーフェイス作成されます。元のソース ビュー切り替えると、デザイン時のコントロールマークアップ保持されWeb ページ既存マークアップ追加されます。MenuDesigner クラスは、ビジュアルなデザイナで、Menu コントロールデザイン時に使用できるようにします。

ActionLists プロパティは、DesignerActionListCollection オブジェクト返します一般にこのオブジェクトには、デザイナ継承ツリーの各レベルについて、DesignerActionList クラスから派生したオブジェクト格納されます。AutoFormats プロパティは、[オートフォーマット] ダイアログ ボックス表示するための書式指定スキームコレクション返します

TemplateGroups プロパティは、関連付けられた Menu コントロールテンプレートについて、テンプレート グループコレクション返します。UsePreviewControl プロパティは、常に true返しますデザイナは、関連付けられた Menu一時的なコピー作成してデザイン時のマークアップ生成します

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

使用例使用例

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

この例では、MyMenu クラスMenu から派生させています。MyMenu クラスは、Menuコピーです。また、この例では、MenuDesigner クラスから MyMenuDesigner クラス派生しMyMenu クラスMyMenuDesigner に DesignerAttribute 属性適用してます。

The MyMenuDesigner は、次の MenuDesignerメンバオーバーライドます。

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.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.HierarchicalDataBoundControlDesigner
            System.Web.UI.Design.WebControls.MenuDesigner
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MenuDesigner メンバ
System.Web.UI.Design.WebControls 名前空間
Menu
HierarchicalDataBoundControl
HierarchicalDataBoundControlDesigner クラス
BaseDataBoundControlDesigner クラス
ControlDesigner クラス
HtmlControlDesigner クラス
ComponentDesigner
その他の技術情報
ASP.NET コントロール デザイナ概要
チュートリアル : Web サーバー コントロール用の基本的なコントロール デザイナ作成


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

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

辞書ショートカット

すべての辞書の索引

「MenuDesigner クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS