Skip to main content

ToolbarCustomCssListEditItem.PreviewStyle Property

Gets style settings that define the preview appearance of the item.

Namespace: DevExpress.Web.ASPxHtmlEditor

Assembly: DevExpress.Web.ASPxHtmlEditor.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

public CustomCssItemPreviewStyle PreviewStyle { get; }

Property Value

Type Description
CustomCssItemPreviewStyle

A CustomCssItemPreviewStyle object that contains style settings.

Example

This example demonstrates how to programmatically create the standard toolbar item of the ToolbarCustomCssEdit type, and add the CSS file to the web project.

In order to specify a css file that contains definitions of custom css classes, the ASPxHtmlEditor.CssFiles property of the ASPxHtmlEditor can be used. The display text of an editor item can be defined using the item’s ListEditItem.Text property. An item’s ToolbarCustomCssListEditItem.CssClass and ToolbarCustomCssListEditItem.TagName properties are used to associate the item with the corresponding css class name, which defines a specific formatting, and specify the name of a tag to wrap the text content to which the associated style will be applied. The preview style of the item displayed within the drop down list of the ToolbarCustomCssEdit object is defined by using the ToolbarCustomCssListEditItem.PreviewStyle property.

<dx:ASPxHtmlEditor ID="ASPxHtmlEditor1" runat="server">
</dx:ASPxHtmlEditor>
protected void Page_Load(object sender, EventArgs e) {
    HtmlEditorCssFile myCss = new HtmlEditorCssFile();
    myCss.FilePath = "~/Css/Custom.css";
    ASPxHtmlEditor1.CssFiles.Add(myCss);
    CustomToolbar myToolbar = new CustomToolbar();
    ToolbarCustomCssEdit myToolbarButton1 = new ToolbarCustomCssEdit();
    ToolbarCustomCssListEditItem CustomStyle1 = 
        new ToolbarCustomCssListEditItem("Header1", "h1", "CommonHeader1");
    ToolbarCustomCssListEditItem CustomStyle2 = 
        new ToolbarCustomCssListEditItem("Header2", "h2", "CommonHeader2");
    CustomStyle1.PreviewStyle.CssClass = "CommonHeader1";
    CustomStyle2.PreviewStyle.CssClass = "CommonHeader2";
    myToolbarButton1.Items.Add(CustomStyle1);
    myToolbarButton1.Items.Add(CustomStyle2);
    myToolbar.Items.Add(myToolbarButton1);
    ASPxHtmlEditor1.Toolbars.Add(myToolbar);
}
See Also