Skip to main content
A newer version of this page is available. .

GridColumn.Caption Property

Gets or sets the column’s display caption.

Namespace: DevExpress.XtraGrid.Columns

Assembly: DevExpress.XtraGrid.v19.2.dll

Declaration

[DXCategory("Appearance")]
[DefaultValue("")]
[XtraSerializableProperty]
public virtual string Caption { get; set; }

Property Value

Type Default Description
String String.Empty

A String value specifying the column’s display caption.

Remarks

In Grid Views, columns’ captions are displayed in column headers. In Card and Layout Views, captions identify individual card fields.

By default, the Caption property is set to an empty string. In this instance, a friendly caption is generated for a column based on its GridColumn.FieldName property. Friendly captions are generated adding SPACE characters between parts of the field name starting with uppercase letters. For example, if the field name is “CustomerName”, the display caption will be “Customer Name”. To override the default display caption, assign it to the Caption property.

In Layout Views, the actual display captions are generated according to the pattern specified by the LayoutView.FieldCaptionFormat property.

To return the actual captions in Layout Views, use the LayoutView.GetFieldCaption method, while in other Views, use the GridColumn.GetCaption method.

If the GridOptionsView.AllowHtmlDrawHeaders property is set to true, you can use HTML tags to format the GridColumn.Caption and GridBand.Caption. For detailed information, see HTML Text Formatting.

Example

The following example shows how to format the GridColumn.Caption using HTML tags. HTML formatting is enabled via the GridOptionsView.AllowHtmlDrawHeaders property. The image below shows the result:

gridColumn_HTML_formatting

gridColumn1.Caption = "Delivery<br/><b>Date</b>";

gridView1.OptionsView.AllowHtmlDrawHeaders = true;
gridView1.Appearance.HeaderPanel.Options.UseTextOptions = true;
gridView1.Appearance.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;

The following code snippets (auto-collected from DevExpress Examples) contain references to the Caption 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.

See Also