EditorPartChromeとは? わかりやすく解説

EditorPartChrome クラス

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

開発者が、EditorZoneBase ゾーン内の EditorPart コントロールの選択したセクションの表示だけをオーバーライドできるようにします。

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

Public Class EditorPartChrome
Dim instance As EditorPartChrome
public class EditorPartChrome
public ref class EditorPartChrome
public class EditorPartChrome
public class EditorPartChrome
解説解説

クロムとは、各 Web パーツ コントロールまたはゾーン内に含まれるサーバー コントロールの周囲に表示する周辺ユーザー インターフェイス (UI: User Interface) 要素のことです。コントロールのクロムには、境界線、タイトル バー、アイコン、タイトル テキストがあり、さらにはタイトル バーに表示される動詞メニューも含まれます。クロムの外観は、ゾーン レベルに対して設定され、ゾーン内のすべてのコントロールに適用されます。

Web パーツ コントロール セットは、EditorPartChrome クラスを使用して EditorPart コントロールのクロムを表示します。また、このクラスを使用すると、開発者は EditorZoneBase ゾーン内の任意の EditorPart コントロールの表示をカスタマイズできます。たとえば、CreateEditorPartChromeStyle メソッドをオーバーライドして、EditorZoneBase ゾーンで定義されている特定のスタイル属性の一部をカスタマイズできます。

EditorPartChrome クラスには、EditorPart コントロールの表示をオーバーライドする場合に役立つ複数の重要なメソッドが含まれています。1 つは、EditorPartChrome コンストラクタです。このコンストラクタは、カスタム EditorZoneBase クラスの CreateEditorPartChrome メソッドをオーバーライドして、カスタム EditorPartChrome オブジェクトのインスタンスを作成する場合に使用します。また RenderPartContents メソッドも役立ちます。このメソッドは、 ヘッダー、フッター、タイトル バーなどのクロム要素とは異なるように、ゾーン内の コントロールのコンテンツ領域の表示を制御する場合に使用できます。最後に、EditorPart コントロールの表示のあらゆる要素をプログラムで完全に制御する場合には、RenderEditorPart メソッドをオーバーライドできます。

実装時の注意 EditorPartChrome クラスから継承する場合、カスタマイズした EditorPartChrome クラスを返すためにカスタマイズした EditorZone ゾーンを作成する必要があります。このクラスの概要の「使用例」は、カスタマイズした EditorZone ゾーンを作成し、カスタマイズした EditorPartChrome クラスを返す方法を示しています。

使用例使用例

EditorPartChrome クラスを使用して EditorZoneBase ゾーンの EditorPart コントロールの既定の表示をオーバーライドする方法を次のコード例に示します。

コード例は、次の 3 つの部分で構成されます。

コード例の最初の部分は、ユーザー コントロールです。ユーザー コントロールのソース コードは、別のトピックのものを使用しています。このコード例を実行するには、チュートリアル : Web パーツ ページでの表示モードの変更 のトピックに記載されているユーザー コントロールの .ascx ファイルを、このコード例に示されている .ascx ページと同じフォルダに配置する必要があります。

コード例の 2 番目の部分は Web ページです。コンパイルしたコンポーネントとタグ プリフィックスを登録するため、ファイルの先頭近くには、Register ディレクティブが存在します。また、このページは、<aspSample:MyEditorZone> 要素を使用してカスタム エディタ ゾーンを参照しています。

<%@ Page Language="VB" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.VB.Controls"
 %>
<%@ Register TagPrefix="uc1" TagName="DisplayModeMenuVB"
 Src="~/DisplayModeMenuVB.ascx" %>
<html>
<head id="Head1" runat="server">
  <title>Web Parts Page</title>
</head>
<body>
  <h1>Web Parts Demonstration Page</h1>
  <form runat="server" id="form1">
<asp:webpartmanager id="WebPartManager1" runat="server"
 />
<uc1:DisplayModeMenuVB runat=server ID="DisplayModeMenu"
 />
  <br />
  <table cellspacing="0" cellpadding="0"
 border="0">
    <tr>
      <td valign="top">
    <asp:webpartzone id="SideBarZone" runat="server"
 
        headertext="Sidebar">
        <zonetemplate>
        </zonetemplate>
      </asp:webpartzone>
      <aspSample:MyEditorZone ID="EditorZone1"
 runat="server">
      <ZoneTemplate>
        <asp:AppearanceEditorPart ID="AppearanceEditorPart1"
 
          runat="server" />
        <asp:LayoutEditorPart ID="LayoutEditorPart1"
 
          runat="server" />
      </ZoneTemplate>
    </aspSample:MyEditorZone>
      </td>
      <td valign="top">
    <asp:webpartzone id="MainZone" runat="server"
 headertext="Main">
         <zonetemplate>
        <asp:label id="contentPart" runat="server"
 title="Content">
              <h2>Welcome to My Home Page</h2>
              <p>Use links to visit my favorite sites!</p>
            </asp:label>
         </zonetemplate>
       </asp:webpartzone>
      </td>
      <td valign="top">
      </td>
    </tr>
  </table>
  </form>
</body>
</html>
<%@ Page Language="C#" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.CS.Controls" %>
<%@ Register TagPrefix="uc1" TagName="DisplayModeMenuCS" Src="~/DisplayModeMenuCS.ascx"
 %>
<html>
<head id="Head1" runat="server">
  <title>Web Parts Page</title>
</head>
<body>
  <h1>Web Parts Demonstration Page</h1>
  <form runat="server" id="form1">
<asp:webpartmanager id="WebPartManager1" runat="server" />
<uc1:DisplayModeMenuCS runat=server ID="DisplayModeMenu" />
  <br />
  <table cellspacing="0" cellpadding="0" border="0">
    <tr>
      <td valign="top">
    <asp:webpartzone id="SideBarZone" runat="server" 
        headertext="Sidebar">
        <zonetemplate>
        </zonetemplate>
      </asp:webpartzone>
      <aspSample:MyEditorZone ID="EditorZone1" runat="server">
      <ZoneTemplate>
        <asp:AppearanceEditorPart ID="AppearanceEditorPart1" 
          runat="server" />
        <asp:LayoutEditorPart ID="LayoutEditorPart1" 
          runat="server" />
      </ZoneTemplate>
    </aspSample:MyEditorZone>
      </td>
      <td valign="top">
    <asp:webpartzone id="MainZone" runat="server" headertext="Main">
         <zonetemplate>
        <asp:label id="contentPart" runat="server" title="Content">
              <h2>Welcome to My Home Page</h2>
              <p>Use links to visit my favorite sites!</p>
            </asp:label>
         </zonetemplate>
       </asp:webpartzone>
      </td>
      <td valign="top">
      </td>
    </tr>
  </table>
  </form>
</body>
</html>

コード例の 3 番目の部分は、カスタムのエディタ パーツ クロムとエディタ パーツ ゾーンの実装を含んでいます。MyEditorZone は EditorZone を拡張し、CreateEditorPartChrome をオーバーライドして、カスタムのエディタ パーツ クロムを返します。MyEditorPartChrome は、CreateEditorPartChromeStyle メソッドのエディタ パーツ コントロールの背景色を変更します。ゾーンの背景色は PerformPreRender メソッドで変更され、RenderPartContents メソッドでエディタ パーツにテキストが追加されます。

Namespace Samples.AspNet.VB.Controls


    <AspNetHostingPermission(SecurityAction.Demand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class MyEditorPartChrome
        Inherits EditorPartChrome

        Public Sub New(ByVal
 zone As EditorZoneBase)
            MyBase.New(zone)
        End Sub

        Protected Overrides Function
 CreateEditorPartChromeStyle(ByVal editorPart As
 System.Web.UI.WebControls.WebParts.EditorPart, ByVal chromeType As System.Web.UI.WebControls.WebParts.PartChromeType) As
 System.Web.UI.WebControls.Style
            Dim editorStyle As Style
            editorStyle = MyBase.CreateEditorPartChromeStyle(editorPart,
 chromeType)
            editorStyle.BackColor = Drawing.Color.Bisque
            Return editorStyle
        End Function

        Public Overrides Sub
 PerformPreRender()
            Dim zoneStyle As Style = New
 Style
            zoneStyle.BackColor = Drawing.Color.Cornsilk

            Zone.Page.Header.StyleSheet.RegisterStyle(zoneStyle, Nothing)
            Zone.MergeStyle(zoneStyle)
        End Sub

        Protected Overrides Sub
 RenderPartContents(ByVal writer As System.Web.UI.HtmlTextWriter,
 ByVal editorPart As System.Web.UI.WebControls.WebParts.EditorPart)
            writer.AddStyleAttribute("color", "red")
            writer.RenderBeginTag("p")
            writer.Write("Apply all changes")
            writer.RenderEndTag()
            editorPart.RenderControl(writer)
        End Sub

        Public Overrides Sub
 RenderEditorPart(ByVal writer As System.Web.UI.HtmlTextWriter,
 ByVal editorPart As System.Web.UI.WebControls.WebParts.EditorPart)
            MyBase.RenderEditorPart(writer, editorPart)
        End Sub
    End Class


    <AspNetHostingPermission(SecurityAction.Demand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class MyEditorZone
        Inherits EditorZone

        Protected Overrides Function
 CreateEditorPartChrome() As System.Web.UI.WebControls.WebParts.EditorPartChrome
            Return New MyEditorPartChrome(Me)
        End Function
    End Class
End Namespace
namespace Samples.AspNet.CS.Controls
{

    [AspNetHostingPermission(SecurityAction.Demand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyEditorPartChrome : EditorPartChrome
    {
        public MyEditorPartChrome(EditorZoneBase zone)
            : base(zone)
        {

        }
        
        protected override Style CreateEditorPartChromeStyle(EditorPart
 editorPart, PartChromeType chromeType)
        {
            Style editorStyle = base.CreateEditorPartChromeStyle(editorPart,
 chromeType);
            editorStyle.BackColor = Color.Bisque;
            return editorStyle;
        }

        public override void PerformPreRender()
        {
            Style zoneStyle = new Style();
            zoneStyle.BackColor = Color.Cornsilk;

            Zone.Page.Header.StyleSheet.RegisterStyle(zoneStyle, null);
            Zone.MergeStyle(zoneStyle);
        }

        protected override void RenderPartContents(HtmlTextWriter
 writer, EditorPart editorPart)
        {
            writer.AddStyleAttribute("color", "red");
            writer.RenderBeginTag("p");
            writer.Write("Apply all changes");
            writer.RenderEndTag();
            editorPart.RenderControl(writer);
        }

        public override void RenderEditorPart(HtmlTextWriter
 writer, EditorPart editorPart)
        {
            base.RenderEditorPart(writer, editorPart);
        }
    }

    [AspNetHostingPermission(SecurityAction.Demand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyEditorZone : EditorZone
    {
        protected override EditorPartChrome CreateEditorPartChrome()
        {
            return new MyEditorPartChrome(this);
        }
    }
}
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
  System.Web.UI.WebControls.WebParts.EditorPartChrome
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EditorPartChrome メンバ
System.Web.UI.WebControls.WebParts 名前空間

EditorPartChrome コンストラクタ

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

EditorPartChrome クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    zone As EditorZoneBase _
)
Dim zone As EditorZoneBase

Dim instance As New EditorPartChrome(zone)
public EditorPartChrome (
    EditorZoneBase zone
)
public:
EditorPartChrome (
    EditorZoneBase^ zone
)
public EditorPartChrome (
    EditorZoneBase zone
)
public function EditorPartChrome (
    zone : EditorZoneBase
)

パラメータ

zone

関連付けられた EditorZoneBase。

例外例外
例外の種類条件

ArgumentNullException

zone が参照する EditorZoneBase が null 参照 (Visual Basic では Nothing) です。

解説解説

EditorPartChrome コンストラクタは、EditorPartChrome クラスの新しいインスタンスを初期化します。これは、主に EditorZoneBase ゾーンによってその CreateEditorPartChrome メソッド内で使用され、クロムのレンダリングおよびそのゾーン内の EditorPart コントロールの任意のカスタム レンダリングを処理する EditorPartChrome オブジェクトのインスタンスを作成します。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EditorPartChrome クラス
EditorPartChrome メンバ
System.Web.UI.WebControls.WebParts 名前空間

EditorPartChrome プロパティ


プロテクト プロパティプロテクト プロパティ

  名前 説明
プロテクト プロパティ Zone 関連付けられた EditorZoneBase ゾーンへの参照を取得します。
参照参照

関連項目

EditorPartChrome クラス
System.Web.UI.WebControls.WebParts 名前空間

EditorPartChrome メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

EditorPartChrome クラス
System.Web.UI.WebControls.WebParts 名前空間

EditorPartChrome メンバ

開発者が、EditorZoneBase ゾーン内の EditorPart コントロールの選択したセクションの表示だけをオーバーライドできるようにします。

EditorPartChrome データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド EditorPartChrome EditorPartChrome クラスの新しいインスタンスを初期化します。
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ Zone 関連付けられた EditorZoneBase ゾーンへの参照を取得します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

EditorPartChrome クラス
System.Web.UI.WebControls.WebParts 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「EditorPartChrome」の関連用語

EditorPartChromeのお隣キーワード
検索ランキング

   

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



EditorPartChromeのページの著作権

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

©2026 GRAS Group, Inc.RSS