Back to Devexpress

TableCell.Range Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-tablecell-619edfe8.md

latest4.8 KB
Original Source

TableCell.Range Property

Gets a document range that contains the cell content, including the table paragraph mark.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
DocumentRange Range { get; }
vb
ReadOnly Property Range As DocumentRange

Property Value

TypeDescription
DocumentRange

A range with the cell content.

|

Remarks

The Range property returns the range with the whole cell (including the table paragraph mark). The ContentRange property returns the range occupied by the cell content.

The image below illustrates the difference between Range and ContentRange values:

Use the Range property to format cell content, as shown below:

csharp
using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
  Document document = wordProcessor.Document;
  Table table = document.Tables[0];
  TableCell headerCell = table[0, 1];

  // Insert text to the cell
  document.InsertSingleLineText(headerCell.Range.Start, "Active Customers");

  // Apply formatting to the "Active Customers" cell
  CharacterProperties properties =
       document.BeginUpdateCharacters(headerCell.Range);
  properties.FontName = "Segoe UI";
  properties.FontSize = 16;
  document.EndUpdateCharacters(properties);
}
vb
Using wordProcessor As New RichEditDocumentServer()
  Dim document As Document = wordProcessor.Document
  Dim table As Table = document.Tables(0)
  Dim headerCell As TableCell = table(0, 1)

  ' Insert text to the cell
  document.InsertSingleLineText(headerCell.Range.Start, "Active Customers")

  ' Apply formatting to the "Active Customers" cell
  Dim properties As CharacterProperties =
       document.BeginUpdateCharacters(headerCell.Range)
  properties.FontName = "Segoe UI"
  properties.FontSize = 16
  document.EndUpdateCharacters(properties)
End Using

The following code snippets (auto-collected from DevExpress Examples) contain references to the Range 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-tables-simple-example/CS/TablesSimpleExample/Form1.cs#L158

csharp
// Format "Rentals" cells
CharacterProperties rentalFormat = document.BeginUpdateCharacters(table[3, 4].Range);
rentalFormat.FontSize = 28;

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

csharp
//Format "Rentals" cells
CharacterProperties rentalFormat = document.BeginUpdateCharacters(table[3, 3].Range);
rentalFormat.FontSize = 28;

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

vb
' Format "Rentals" cells
Dim rentalFormat As CharacterProperties = document.BeginUpdateCharacters(table(3, 4).Range)
rentalFormat.FontSize = 28

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

vb
'Format "Rentals" cells
Dim rentalFormat As CharacterProperties = document.BeginUpdateCharacters(table(3, 3).Range)
rentalFormat.FontSize = 28

See Also

TableCell Interface

TableCell Members

DevExpress.XtraRichEdit.API.Native Namespace