Skip to main content
All docs
V19.2

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 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 as shown in the code sample below.

Table Element

Property

Value

Table

Table.TableLayout

Table.PreferredWidthType

TableLayoutType.Fixed

WidthType.Fixed

Cell

TableCell.PreferredWidthType

TableCell.PreferredWidth

WidthType.Fixed

A floating point value specifying the cell width. To avoid dimensional changes at runtime, convert this value to document units of measurement (determined by the Document.Unit property). To do that, use the corresponding Units class method.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/wpf-richedit-document-api-t213968.

Table table = document.Tables.Create(document.Range.Start, 3, 3);

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

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

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

The image below illustrates the result of the code execution.

APIExamples_Tables_FixedColumnWidth