Skip to main content

How to: Create a Table with Fixed Column Width

To create a table with fixed column widths, specify the following settings:

Property Value
For the table set the Table.TableLayout TableLayoutType.Fixed
For the table set the Table.PreferredWidthType WidthType.Fixed
For each cell set the TableCell.PreferredWidthType WidthType.Fixed
For each cell set the TableCell.PreferredWidth A floating point value specifying the cell width measured in document units of measurement determined by the Document.Unit property.

View Example

using XtraRichEdit.API.Native;
using DevExpress.Office.Utils;

using (var wordProcessor = new richEditDocumentServer())
    Document document = wordProcessor.Document;
    Table table = document.Tables.Create(document.Range.Start, 3, 3);

    table.TableAlignment = TableRowAlignment.Center;
    table.TableLayout = TableLayoutType.Fixed;
    table.PreferredWidthType = WidthType.Fixed;
    table.PreferredWidth = .Units.InchesToDocumentsF(4f);

    table.Rows[1].HeightType = HeightType.Exact;
    table.Rows[1].Height = Units.InchesToDocumentsF(0.8f);

    table[1, 1].PreferredWidthType = WidthType.Fixed;
    table[1, 1].PreferredWidth = Units.InchesToDocumentsF(1.5f);

    table.MergeCells(table[1, 1], table[2, 1]);