EditorPartChrome.CreateEditorPartChromeStyle(EditorPart, PartChromeType) 方法

定义

创建样式对象,该对象为 EditorPart 对象呈现的每个 EditorPartChrome 控件提供样式特性。Creates the style object that supplies style attributes for each EditorPart control rendered by the EditorPartChrome object.

protected:
 virtual System::Web::UI::WebControls::Style ^ CreateEditorPartChromeStyle(System::Web::UI::WebControls::WebParts::EditorPart ^ editorPart, System::Web::UI::WebControls::WebParts::PartChromeType chromeType);
protected virtual System.Web.UI.WebControls.Style CreateEditorPartChromeStyle (System.Web.UI.WebControls.WebParts.EditorPart editorPart, System.Web.UI.WebControls.WebParts.PartChromeType chromeType);
abstract member CreateEditorPartChromeStyle : System.Web.UI.WebControls.WebParts.EditorPart * System.Web.UI.WebControls.WebParts.PartChromeType -> System.Web.UI.WebControls.Style
override this.CreateEditorPartChromeStyle : System.Web.UI.WebControls.WebParts.EditorPart * System.Web.UI.WebControls.WebParts.PartChromeType -> System.Web.UI.WebControls.Style
Protected Overridable Function CreateEditorPartChromeStyle (editorPart As EditorPart, chromeType As PartChromeType) As Style

参数

editorPart
EditorPart

当前正在呈现的控件。The control that is currently being rendered.

chromeType
PartChromeType

特定控件的 chrome 类型;PartChromeType 枚举值之一。The type of chrome for a particular control; one of the PartChromeType enumeration values.

返回

Style

包含 editorPart 的样式特性的 StyleA Style that contains style attributes for editorPart.

例外

editorPart 引用的控件为 nullThe control that editorPart refers to is null.

chromeType 不是 PartChromeTypechromeType is not a PartChromeType.

示例

下面的代码示例演示如何重写 CreateEditorPartChromeStyle 方法以更改编辑器部件控件的背景色。The following code example demonstrates how to override the CreateEditorPartChromeStyle method to change the background color of the editor part control. 有关运行示例所需的完整代码(包括承载这些控件的网页),请参阅类概述的 "示例" 部分 EditorPartChromeFor the full code required to run the example, including the Web page to host these controls, see the Example section of the EditorPartChrome class overview.

protected override Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType)
{
    Style editorStyle = base.CreateEditorPartChromeStyle(editorPart, chromeType);
    editorStyle.BackColor = Color.Bisque;
    return editorStyle;
}
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

注解

CreateEditorPartChromeStyle方法创建对象 StyleEditorPartChrome 来呈现控件的对象 EditorPartThe CreateEditorPartChromeStyle method creates a Style object that is used by the EditorPartChrome object to render an EditorPart control.

继承者说明

如果从 EditorPartChrome 类继承,则可以选择重写 CreateEditorPartChromeStyle(EditorPart, PartChromeType) 方法,并将基方法中的样式信息与要添加的自定义样式属性合并。If you inherit from the EditorPartChrome class, you can optionally override the CreateEditorPartChromeStyle(EditorPart, PartChromeType) method, and merge the style information from the base method with custom style attributes that you want to add. 有关演示,请参阅 "示例" 部分。For a demonstration, see the Example section.

适用于