Back to Devexpress

Table.HorizontalAlignment Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-table-6b090ae9.md

latest9.5 KB
Original Source

Table.HorizontalAlignment Property

Gets or sets how the table’s horizontal alignment.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
TableHorizontalAlignment HorizontalAlignment { get; set; }
vb
Property HorizontalAlignment As TableHorizontalAlignment

Property Value

TypeDescription
TableHorizontalAlignment

An enumeration value that indicates the table’s horizontal position.

|

Available values:

NameDescription
None

The exact position is specified by the Table.OffsetXRelative property.

| | Left |

The table is left aligned relative to its Table.RelativeHorizontalPosition.

| | Center |

The table is centered relative to its Table.RelativeHorizontalPosition.

| | Right |

The table is right aligned relative to its Table.RelativeHorizontalPosition.

| | Inside |

The table is inside relative to the element specified by the Table.RelativeHorizontalPosition. Not currently supported.

| | Outside |

The table is outside relative to the element specified by the Table.RelativeHorizontalPosition. Not currently supported.

|

Remarks

The HorizontalAlignment property value is ignored for tables with the Table.TextWrappingType property set to TableTextWrappingType.None.

The HorizontalAlignment property defines the alignment relative to the element specified in the Table.RelativeHorizontalPosition property. If the HorizontalAlignment property is set to None, the Table.OffsetXRelative property specifies the table’s position.

Note

The TableHorizontalAlignment.Inside and TableHorizontalAlignment.Outside values are ignored when the document is opened in the RichEditControl. You can set this property in code and save its value to a file for further processing in Microsoft Word or other word processing applications.

The code sample below shows how to specify the table’s horizontal alignment:

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;

using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
  Document document = wordProcessor.Document;
  Table table = document.Tables[0];
  table.BeginUpdate();
  //Wrap text around the table
  table.TextWrappingType = TableTextWrappingType.Around;

  //Specify horizontal alignment:
  table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin;
  table.HorizontalAlignment = TableHorizontalAlignment.Center;

  table.EndUpdate();
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native

Using wordProcessor As New RichEditDocumentServer()
  Dim document As Document = wordProcessor.Document
  Dim table As Table = document.Tables(0)
  table.BeginUpdate()
  'Wrap text around the table
  table.TextWrappingType = TableTextWrappingType.Around

  'Specify horizontal alignment:
  table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin
  table.HorizontalAlignment = TableHorizontalAlignment.Center

  table.EndUpdate()
End Using

The following code snippets (auto-collected from DevExpress Examples) contain references to the HorizontalAlignment property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Table.cs#L278

csharp
table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin;
table.HorizontalAlignment = TableHorizontalAlignment.Center;

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/TableActions.cs#L281

csharp
table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin;
table.HorizontalAlignment = TableHorizontalAlignment.Center;

winforms-richedit-tables-simple-example/CS/TablesSimpleExample/Form1.cs#L92

csharp
table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin;
table.HorizontalAlignment = TableHorizontalAlignment.Center;

word-document-api-examples/CS/CodeExamples/TablesActions.cs#L391

csharp
table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin;
table.HorizontalAlignment = TableHorizontalAlignment.Center;

word-document-api-table-examples/CS/Program.cs#L227

csharp
table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin;
table.HorizontalAlignment = TableHorizontalAlignment.Center;
table.OffsetXRelative = Units.InchesToDocumentsF(2f);

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Table.vb#L249

vb
table.RelativeHorizontalPosition = DevExpress.XtraRichEdit.API.Native.TableRelativeHorizontalPosition.Margin
table.HorizontalAlignment = DevExpress.XtraRichEdit.API.Native.TableHorizontalAlignment.Center
'Set distance between the text and the table:

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/TableActions.vb#L250

vb
table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin
table.HorizontalAlignment = TableHorizontalAlignment.Center

winforms-richedit-tables-simple-example/VB/TablesSimpleExample/Form1.vb#L75

vb
table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin
table.HorizontalAlignment = TableHorizontalAlignment.Center
' Set distance between the text and the table:

word-document-api-examples/VB/CodeExamples/TablesActions.vb#L331

vb
table.RelativeHorizontalPosition = DevExpress.XtraRichEdit.API.Native.TableRelativeHorizontalPosition.Margin
table.HorizontalAlignment = DevExpress.XtraRichEdit.API.Native.TableHorizontalAlignment.Center
' Set distance between the text and the table.

word-document-api-table-examples/VB/Program.vb#L183

vb
table.RelativeHorizontalPosition = TableRelativeHorizontalPosition.Margin
table.HorizontalAlignment = TableHorizontalAlignment.Center
table.OffsetXRelative = Units.InchesToDocumentsF(2F)

See Also

Table Interface

Table Members

DevExpress.XtraRichEdit.API.Native Namespace