.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

TableStyle Interface

A single style that can be applied to a table.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v19.2.Core.dll

Declaration

[ComVisible(true)]
public interface TableStyle :
    TablePropertiesBase,
    TableCellPropertiesBase,
    CharacterPropertiesBase,
    ParagraphPropertiesBase
<ComVisible(True)>
Public Interface TableStyle
    Inherits TablePropertiesBase,
             TableCellPropertiesBase,
             CharacterPropertiesBase,
             ParagraphPropertiesBase
[ComVisible(true)]
public interface TableStyle :
    TablePropertiesBase,
    TableCellPropertiesBase,
    CharacterPropertiesBase,
    ParagraphPropertiesBase
<ComVisible(True)>
Public Interface TableStyle
    Inherits TablePropertiesBase,
             TableCellPropertiesBase,
             CharacterPropertiesBase,
             ParagraphPropertiesBase
[ComVisible(true)]
public interface TableStyle :
    TablePropertiesBase,
    TableCellPropertiesBase,
    CharacterPropertiesBase,
    ParagraphPropertiesBase
<ComVisible(True)>
Public Interface TableStyle
    Inherits TablePropertiesBase,
             TableCellPropertiesBase,
             CharacterPropertiesBase,
             ParagraphPropertiesBase

Remarks

The TableStyle object inherits the CharacterPropertiesBase, ParagraphPropertiesBase, TableCellPropertiesBase and the TablePropertiesBase interfaces.

Table styles are contained within the TableStyleCollection accessible via the Document.TableStyles property. To create a new style, use the TableStyleCollection.CreateNew method. Subsequently you should add a style to the document style collection, otherwise you won't be able to apply it.

To apply a style to a table, use the Table.Style property.

Note that each paragraph in a cell may have its own style.

Default table formatting can be specified via the Document.DefaultTableProperties property.

Examples

Document document = server.Document;
document.BeginUpdate();
// Create a new table style.
TableStyle tStyleMain = document.TableStyles.CreateNew();
// Specify style characteristics.
tStyleMain.AllCaps = true;
tStyleMain.FontName = "Segoe Condensed";
tStyleMain.FontSize = 14;
tStyleMain.Alignment = ParagraphAlignment.Center;
tStyleMain.TableBorders.InsideHorizontalBorder.LineStyle = TableBorderLineStyle.Dotted;
tStyleMain.TableBorders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.Dotted;
tStyleMain.TableBorders.Top.LineThickness = 1.5f;
tStyleMain.TableBorders.Top.LineStyle = TableBorderLineStyle.Double;
tStyleMain.TableBorders.Left.LineThickness = 1.5f;
tStyleMain.TableBorders.Left.LineStyle = TableBorderLineStyle.Double;
tStyleMain.TableBorders.Bottom.LineThickness = 1.5f;
tStyleMain.TableBorders.Bottom.LineStyle = TableBorderLineStyle.Double;
tStyleMain.TableBorders.Right.LineThickness = 1.5f;
tStyleMain.TableBorders.Right.LineStyle = TableBorderLineStyle.Double;
tStyleMain.CellBackgroundColor = System.Drawing.Color.LightBlue;
tStyleMain.TableLayout = TableLayoutType.Fixed;
tStyleMain.Name = "MyTableStyle";
//Add the style to the document.
document.TableStyles.Add(tStyleMain);
document.EndUpdate();
document.BeginUpdate();
// Create a table.
Table table = document.Tables.Create(document.Range.Start, 3, 3);
table.TableLayout = TableLayoutType.Fixed;
table.PreferredWidthType = WidthType.Fixed;
table.PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(4.5f);
table[1, 1].PreferredWidthType = WidthType.Fixed;
table[1, 1].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(1.5f);
// Apply a previously defined style.
table.Style = tStyleMain;
document.EndUpdate();

document.InsertText(table[1, 1].Range.Start, "STYLED");
See Also