TextOptions.Trimming Property
Gets or sets text trimming mode.
Namespace: DevExpress.Utils
Assembly: DevExpress.Utils.v24.2.dll
Declaration
[DefaultValue(Trimming.Default)]
[XtraSerializableProperty]
public virtual Trimming Trimming { get; set; }
Property Value
Type | Default | Description |
---|---|---|
Trimming | Default | A Trimming value that specifies text trimming mode. |
Available values:
Name | Description |
---|---|
Default | Trimming is determined by a control’s current settings. The default value is automatically set for a control if an end-user doesn’t specify a value. |
None | Specifies no trimming. |
Character | Specifies that the text is trimmed to the nearest character. |
Word | Specifies that text is trimmed to the nearest word. |
EllipsisCharacter | Specifies that the text is trimmed to the nearest character, and an ellipsis is inserted at the end of a trimmed line. |
EllipsisWord | Specifies that text is trimmed to the nearest word, and an ellipsis is inserted at the end of a trimmed line. |
EllipsisPath | The center is removed from trimmed lines and replaced by an ellipsis. The algorithm keeps as much of the last slash-delimited segment of the line as possible. This mode is not supported if DirectX Hardware Acceleration is enabled. |
Property Paths
You can access this nested property as listed below:
Object Type | Path to Trimming |
---|---|
AppearanceObject |
|
TextOptions |
|
TextOptions |
|
TextOptions |
|
TextOptions |
|
TextOptions |
|
Remarks
The Trimming
property specifies how the characters are trimmed in a string that does not completely fit into the container. See the Trimming topic for a list of available options.
When an AppearanceObject’s style setting (for example, BackColor, ForeColor, Font and TextOptions.HAlignment) is set to a non-default value, the corresponding Options.Use… option (for instance, Options.UseBackColor, Options.UseForeColor, Options.UseFont and Options.UseTextOptions) is automatically set to true in the following cases:
- The AppearanceObject belongs to a control/component (or its element), and this control/component has been completely loaded (see the control’s IsLoading property to check the load status);
- The AppearanceObject belongs to a grid column/band or tree list column/band, and the column/band belongs to a grid/tree list control;
- The AppearanceObject is standalone, that is, it does not belong to any control or component.
In other cases, the Options.Use… options are not automatically enabled. You may need to enable these options manually for the style settings to be in effect.
The code sample below illustrates how to trim long strings in a grid with an ellipsis.
gridView1.Columns["productName"].AppearanceCell.TextOptions.Trimming = Trimming.EllipsisPath;
Important
The DevExpress.Utils.Trimming.EllipsisPath
mode is not supported if DirectX Hardware Acceleration is enabled.
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Trimming 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.