GridColumn.Caption Property

Gets or sets the column's display caption.

Namespace: DevExpress.XtraGrid.Columns

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

[DXCategory("Appearance")]
[DefaultValue("")]
[XtraSerializableProperty]
public virtual string Caption { get; set; }
<DXCategory("Appearance")>
<DefaultValue("")>
<XtraSerializableProperty>
Public Overridable Property Caption As String

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.

Examples

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;
See Also