Back to Devexpress

VGridControl.CustomRecordHeaderDisplayText Event

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrol-fb6f358e.md

latest4.3 KB
Original Source

VGridControl.CustomRecordHeaderDisplayText Event

Allows you to assign text to individual record headers.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

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

Declaration

csharp
[DXCategory("Appearance")]
public event CustomRecordHeaderDisplayTextEventHandler CustomRecordHeaderDisplayText
vb
<DXCategory("Appearance")>
Public Event CustomRecordHeaderDisplayText As CustomRecordHeaderDisplayTextEventHandler

Event Data

The CustomRecordHeaderDisplayText event's data class is DevExpress.XtraVerticalGrid.Events.CustomRecordHeaderDisplayTextEventArgs.

Remarks

Enable the VGridOptionsView.ShowRecordHeaders property to display record headers.

You can specify record header content as follows:

Example

The following example handles the VGridControl.CustomRecordHeaderDisplayText event to assign different text to different record headers. Headers of records that correspond to out-of-stock products display the “Out of stock” string. Other headers display a product’s brand and model information formatted with HTML tags.

csharp
vGridControl.OptionsView.ShowRecordHeaders = true;
vGridControl.OptionsView.AllowHtmlText = true;
vGridControl.Appearance.RecordHeader.TextOptions.WordWrap = WordWrap.Wrap;
//...
private void vGridControl_CustomRecordHeaderDisplayText(object sender, Events.CustomRecordHeaderDisplayTextEventArgs e) {
    VGridControl vGrid = sender as VGridControl;
    bool inStock = (bool)vGrid.GetCellValue("InStock", e.Record);
    if (inStock) {
        string maker = (string)vGrid.GetCellDisplayText(erTrademark.Properties, e.Record);
        string model = (string)vGrid.GetCellDisplayText(erName.Properties, e.Record);
        e.DisplayText = $"<size=+1>{maker}
<size=+2><color=green><b>{model}</b>";
    }
    else
        e.DisplayText = "<color=gray>Out of stock</color>";
}
vb
vGridControl.OptionsView.ShowRecordHeaders = True
vGridControl.OptionsView.AllowHtmlText = True
vGridControl.Appearance.RecordHeader.TextOptions.WordWrap = WordWrap.Wrap
'...
Private Sub VGridControl1_CustomRecordDisplayText(sender As Object, e As Events.CustomRecordDisplayTextEventArgs) Handles VGridControl1.CustomRecordDisplayText
    Dim vGrid As VGridControl = TryCast(sender, VGridControl)
    Dim inStock As Boolean = CBool(vGrid.GetCellValue("InStock", e.Record))

    If inStock Then
        Dim maker As String = CStr(vGrid.GetCellDisplayText(erTrademark.Properties, e.Record))
        Dim model As String = CStr(vGrid.GetCellDisplayText(erName.Properties, e.Record))
        e.DisplayText = $"<size=+1>{maker}
<size=+2><color=green><b>{model}</b>"
    Else
        e.DisplayText = "<color=gray>Out of stock</color>"
    End If
End Sub

See Also

VGridControl Class

VGridControl Members

DevExpress.XtraVerticalGrid Namespace