Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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]);
}