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

CatalogPartChrome クラス

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

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

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

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

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

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

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

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

使用例使用例

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

コード例は、次の 3 つの部分から成ります。

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

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

<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:MyCatalogZone ID="CatalogZone1"
 runat="server">
      <ZoneTemplate>
          <asp:ImportCatalogPart ID="ImportCatalog"
 runat="server" />
      </ZoneTemplate>
    </aspSample:MyCatalogZone>
      </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="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:MyCatalogZone ID="CatalogZone1"
 runat="server">
      <ZoneTemplate>
          <asp:ImportCatalogPart ID="ImportCatalog"
 runat="server" />
      </ZoneTemplate>
    </aspSample:MyCatalogZone>
      </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:MyCatalogZone ID="CatalogZone1" runat="server">
      <ZoneTemplate>
          <asp:ImportCatalogPart ID="ImportCatalog" runat="server"
 />
      </ZoneTemplate>
    </aspSample:MyCatalogZone>
      </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 番目の部分には、カスタムのカタログ パーツ クロムおよびカタログ パーツ ゾーンの実装が含まれています。MyCatalogZone は CatalogZone を拡張して CreateCatalogPartChrome をオーバーライドし、カスタムのカタログ パーツ クロムを返します。MyCatalogPartChrome は、CreateCatalogPartChromeStyle メソッドのカタログ コントロールの背景色を変更します。ゾーンの背景色は PerformPreRender メソッドで変更し、テキストは RenderPartContents メソッドでカタログ パーツに追加されます。

Namespace Samples.AspNet.VB.Controls


    Public Class MyCatalogPartChrome
        Inherits CatalogPartChrome

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

        Protected Overrides Function
 CreateCatalogPartChromeStyle(ByVal catalogPart As
 System.Web.UI.WebControls.WebParts.CatalogPart, ByVal chromeType As System.Web.UI.WebControls.WebParts.PartChromeType) As
 System.Web.UI.WebControls.Style
            Dim editorStyle As Style
            editorStyle = MyBase.CreateCatalogPartChromeStyle(catalogPart,
 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 catalogPart As System.Web.UI.WebControls.WebParts.CatalogPart)
            writer.AddStyleAttribute("color", "red")
            writer.RenderBeginTag("p")
            writer.Write("Apply all changes")
            writer.RenderEndTag()
            catalogPart.RenderControl(writer)
        End Sub

        Public Overrides Sub
 RenderCatalogPart(ByVal writer As System.Web.UI.HtmlTextWriter,
 ByVal catalogPart As System.Web.UI.WebControls.WebParts.CatalogPart)
            MyBase.RenderCatalogPart(writer, catalogPart)
        End Sub
    End Class

    Public Class MyCatalogZone
        Inherits CatalogZone

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

    /// <summary>
    /// Summary description for source
    /// </summary>
    public class MyCatalogPartChrome : CatalogPartChrome
    {
        public MyCatalogPartChrome(CatalogZoneBase zone)
            : base(zone)
        {

        }

        protected override Style  CreateCatalogPartChromeStyle(CatalogPart
 catalogPart, PartChromeType chromeType)
        {
            Style catalogStyle = base.CreateCatalogPartChromeStyle(catalogPart,
 chromeType);
            catalogStyle.BackColor = Color.Bisque;
            return catalogStyle;
        }

        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, CatalogPart catalogPart)
        {
            writer.AddStyleAttribute("color", "red");
            writer.RenderBeginTag("p");
            writer.Write("Apply all changes");
            writer.RenderEndTag();
            catalogPart.RenderControl(writer);
        }

        public override void  RenderCatalogPart(HtmlTextWriter
 writer, CatalogPart catalogPart)
        {
            base.RenderCatalogPart(writer, catalogPart);
        }
    }

    public class MyCatalogZone : CatalogZone
    {
        protected override CatalogPartChrome  CreateCatalogPartChrome()
        {
            return new MyCatalogPartChrome(this);
        }
    }
}
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
  System.Web.UI.WebControls.WebParts.CatalogPartChrome
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CatalogPartChrome メンバ
System.Web.UI.WebControls.WebParts 名前空間
CreateCatalogPartChrome
CatalogPart クラス
WebPartChrome
EditorPartChrome
その他の技術情報
ASP.NET Web パーツ ページ

CatalogPartChrome コンストラクタ

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

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

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

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

Dim instance As New CatalogPartChrome(zone)
public CatalogPartChrome (
    CatalogZoneBase zone
)
public:
CatalogPartChrome (
    CatalogZoneBase^ zone
)
public CatalogPartChrome (
    CatalogZoneBase zone
)
public function CatalogPartChrome (
    zone : CatalogZoneBase
)

パラメータ

zone

関連付けられた CatalogZoneBase。

例外例外
例外の種類条件

ArgumentNullException

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

解説解説

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

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

CatalogPartChrome プロパティ


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

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

関連項目

CatalogPartChrome クラス
System.Web.UI.WebControls.WebParts 名前空間
CreateCatalogPartChrome
CatalogPart クラス
WebPartChrome
EditorPartChrome

その他の技術情報

ASP.NET Web パーツ ページ

CatalogPartChrome メソッド


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

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

関連項目

CatalogPartChrome クラス
System.Web.UI.WebControls.WebParts 名前空間
CreateCatalogPartChrome
CatalogPart クラス
WebPartChrome
EditorPartChrome

その他の技術情報

ASP.NET Web パーツ ページ

CatalogPartChrome メンバ

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

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


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

関連項目

CatalogPartChrome クラス
System.Web.UI.WebControls.WebParts 名前空間
CreateCatalogPartChrome
CatalogPart クラス
WebPartChrome
EditorPartChrome

その他の技術情報

ASP.NET Web パーツ ページ



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「CatalogPartChrome」の関連用語

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

   

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



CatalogPartChromeのページの著作権

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

©2026 GRAS Group, Inc.RSS