Back to Devexpress

RowCellCustomDrawEventArgs.DisplayText Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-rowcellcustomdraweventargs-5a27e3f6.md

latest8.1 KB
Original Source

RowCellCustomDrawEventArgs.DisplayText Property

Gets or sets the painted element’s display text.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public string DisplayText { get; set; }
vb
Public Property DisplayText As String

Property Value

TypeDescription
String

A string value representing the element’s display text.

|

Remarks

Initially, the DisplayText property value contains the element’s default text representation.

If painting a data cell (via the GridView.CustomDrawCell, CardView.CustomDrawCardFieldValue and LayoutView.CustomDrawCardFieldValue events), the DisplayText property returns the cell’s display text formatted as specified by the column’s GridColumn.DisplayFormat property.

If painting a card field (via the CardView.CustomDrawCardField event) and card field caption (via the CardView.CustomDrawCardFieldCaption and LayoutView.CustomDrawCardFieldCaption events), the DisplayText property initially contains the card field caption.

The DisplayText property can be used in two ways:

  • read the property value and manually paint the default text;
  • change the DisplayText property value and leave the event’s CustomDrawEventArgs.Handled parameter set to false. In this case, the element will be painted using the default mechanism but with the modified text.

The following code snippets (auto-collected from DevExpress Examples) contain references to the DisplayText 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-grid-richedit-highlight-search-results/CS/E4422/Form1.cs#L20

csharp
if (e.Column == colDescription && !string.IsNullOrEmpty(gridView1.FindFilterText)) {
    server.RtfText = e.DisplayText;
    Document document = server.Document;

winforms-grid-highlight-cell-values-matching-text-in-autofilterrow/CS/CarsGridWinApp15/Main.cs#L38

csharp
e.Appearance.FillRectangle(e.Cache, e.Bounds);
e.Cache.Paint.DrawMultiColorString(e.Cache, e.Bounds, e.DisplayText, filterCellText, e.Appearance, Color.Black, Color.Gold, false, filterTextIndex);
e.Handled = true;

winforms-grid-show-editor-buttons-on-cell-hover/CS/WindowsApplication3/Form1.cs#L48

csharp
info.EditorButtonPainter.DrawObject(args);
e.Cache.DrawString(e.DisplayText, e.Appearance.Font, e.Appearance.GetForeBrush(e.Cache), textRect, e.Appearance.GetStringFormat());
e.Handled = true;

winforms-diagram-create-custom-toolbox/CS/CustomDiagramToolboxExample/Form1.cs#L42

csharp
{
    e.Appearance.DrawString(e.Cache, e.DisplayText, new Rectangle(e.Bounds.X + shapeTextOffset, e.Bounds.Y, e.Bounds.Width - shapeTextOffset, e.Bounds.Height));
    e.Cache.TranslateTransform(e.Bounds.X, e.Bounds.Y);

winforms-grid-display-icons-in-data-cells/CS/Form1.cs#L244

csharp
if (e.RowHandle != GridControl.NewItemRowHandle && e.Column.FieldName == "CustomDraw") {
    e.DisplayText = string.Empty;
    e.DefaultDraw();

winforms-grid-richedit-highlight-search-results/VB/E4422/Form1.vb#L23

vb
If e.Column Is colDescription AndAlso Not String.IsNullOrEmpty(gridView1.FindFilterText) Then
    server.RtfText = e.DisplayText
    Dim document As Document = server.Document

winforms-grid-highlight-cell-values-matching-text-in-autofilterrow/VB/CarsGridWinApp15/Main.vb#L29

vb
e.Appearance.FillRectangle(e.Cache, e.Bounds)
e.Cache.Paint.DrawMultiColorString(e.Cache, e.Bounds, e.DisplayText, filterCellText, e.Appearance, Color.Black, Color.Gold, False, filterTextIndex)
e.Handled = True

winforms-grid-show-editor-buttons-on-cell-hover/VB/WindowsApplication3/Form1.vb#L51

vb
info.EditorButtonPainter.DrawObject(args)
e.Cache.DrawString(e.DisplayText, e.Appearance.Font, e.Appearance.GetForeBrush(e.Cache), textRect, e.Appearance.GetStringFormat())
e.Handled = True

winforms-diagram-create-custom-toolbox/VB/CustomDiagramToolboxExample/Form1.vb#L43

vb
Try
    e.Appearance.DrawString(e.Cache, e.DisplayText, New System.Drawing.Rectangle(e.Bounds.X + Me.shapeTextOffset, e.Bounds.Y, e.Bounds.Width - Me.shapeTextOffset, e.Bounds.Height))
    e.Cache.TranslateTransform(e.Bounds.X, e.Bounds.Y)

winforms-grid-display-icons-in-data-cells/VB/Form1.vb#L216

vb
If e.RowHandle <> GridControl.NewItemRowHandle AndAlso Equals(e.Column.FieldName, "CustomDraw") Then
    e.DisplayText = String.Empty
    e.DefaultDraw()

See Also

CustomDrawCell

Handled

CellValue

RowCellCustomDrawEventArgs Class

RowCellCustomDrawEventArgs Members

DevExpress.XtraGrid.Views.Base Namespace