Back to Devexpress

GridColumn.GetCaption() Method

windowsforms-devexpress-dot-xtragrid-dot-columns-dot-gridcolumn-23e38b7a.md

latest4.4 KB
Original Source

GridColumn.GetCaption() Method

Returns the actual display caption for the current column.

Namespace : DevExpress.XtraGrid.Columns

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
public virtual string GetCaption()
vb
Public Overridable Function GetCaption As String

Returns

TypeDescription
String

A string that specifies the column’s actual display caption.

|

Remarks

If the GridColumn.Caption property is set to an empty string, a friendly display caption is automatically generated according to the GridColumn.FieldName property. Use the GetCaption method to return the actual display caption. To get the actual display caption in Layout Views, use the LayoutView.GetFieldCaption method.

See GridColumn.Caption to learn more.

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetCaption() method.

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-double-click-row-cell/CS/DoubleClickCell/Form1.cs#L27

csharp
if(info.InRow || info.InRowCell) {
    string colCaption = info.Column == null ? "N/A" : info.Column.GetCaption();
    MessageBox.Show(string.Format("DoubleClick on row: {0}, column: {1}.", info.RowHandle, colCaption));

winforms-grid-display-text-editor-in-column-header/CS/WindowsApplication1/MyGridColumnRenameHelper.cs#L79

csharp
headerEdit.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height);
headerEdit.EditValue = column.GetCaption();
headerEdit.Show();

winforms-grid-double-click-row-cell/VB/DoubleClickCell/Form1.vb#L28

vb
If info.InRow OrElse info.InRowCell Then
    Dim colCaption As String = If(info.Column Is Nothing, "N/A", info.Column.GetCaption())
    MessageBox.Show(String.Format("DoubleClick on row: {0}, column: {1}.", info.RowHandle, colCaption))

winforms-grid-display-text-editor-in-column-header/VB/WindowsApplication1/MyGridColumnRenameHelper.vb#L75

vb
headerEdit.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height)
headerEdit.EditValue = column.GetCaption()
headerEdit.Show()

See Also

Caption

GetFieldCaption(GridColumn)

GridColumn Class

GridColumn Members

DevExpress.XtraGrid.Columns Namespace