Back to Devexpress

ColumnHeaderCustomDrawEventArgs.Column Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-columnheadercustomdraweventargs.md

latest7.3 KB
Original Source

ColumnHeaderCustomDrawEventArgs.Column Property

Gets the GridColumn whose header is to be drawn. Returns null if an “empty column header” is currently being painted.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
public GridColumn Column { get; }
vb
Public ReadOnly Property Column As GridColumn

Property Value

TypeDescription
GridColumn

A GridColumn whose header is to be drawn.

|

Remarks

When the column auto-width feature is disabled (see GridOptionsView.ColumnAutoWidth), the grid View displays an “empty column header” after data columns. In banded grid Views, an “empty band header” and “empty column header” are displayed in this case.

The GridView.CustomDrawColumnHeader event fires repeatedly for each column header, including the “empty column header”. When this event is fired for the “empty column header”, the event’s Column parameter returns null.

Similarly, the BandedGridView.CustomDrawBandHeader event fires in a banded grid View repeatedly for each band header, including the “empty band header”. When this event is fired for the “empty band header”, the event’s Band parameter returns null.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Column 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-add-check-box-to-column-header/CS/GridViewColumnHeaderExtender.cs#L156

csharp
{
    if (e.Column == null) return;
    DefaultDrawColumnHeader(e);

winforms-grid-hot-track-focused-column-header/CS/WindowsApplication1/Form1.cs#L33

csharp
GridView view = sender as GridView;
if (e.Column?.FieldName == view.FocusedColumn.FieldName)
    e.Info.State = ObjectState.Hot;

winforms-grid-multiple-row-selection-web-style-checkboxes/CS/E1271/CheckMarkSelection.cs#L230

csharp
void View_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e) {
    if(e.Column == column) {
        e.Info.InnerElements.Clear();

winforms-grid-display-editors-in-columns-headers/CS/WindowsApplication1/InplaceEditorHelper/ColumnInplaceEditorHelper.cs#L58

csharp
{
    if (e.Column == _Column)
    {

winforms-grid-custom-button-in-column-header/CS/WindowsApplication3/ColumnHeaderExtender.cs#L112

csharp
void OnCustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e) {
    if(e.Column == null) return;
    DefaultDrawColumnHeader(e);

winforms-grid-add-check-box-to-column-header/VB/GridViewColumnHeaderExtender.vb#L147

vb
Private Sub OnCustomDrawColumnHeader(ByVal sender As Object, ByVal e As ColumnHeaderCustomDrawEventArgs)
    If e.Column Is Nothing Then
        Return

winforms-grid-hot-track-focused-column-header/VB/WindowsApplication1/Form1.vb#L35

vb
Dim view As GridView = TryCast(sender, GridView)
    If Equals(e.Column?.FieldName, view.FocusedColumn.FieldName) Then e.Info.State = ObjectState.Hot
End Sub

winforms-grid-multiple-row-selection-web-style-checkboxes/VB/E1271/CheckMarkSelection.vb#L270

vb
Private Sub View_CustomDrawColumnHeader(ByVal sender As Object, ByVal e As ColumnHeaderCustomDrawEventArgs)
    If e.Column Is column Then
        e.Info.InnerElements.Clear()

winforms-grid-display-editors-in-columns-headers/VB/InplaceEditorHelper/ColumnInplaceEditorHelper.vb#L57

vb
Private Sub view_CustomDrawColumnHeader(ByVal sender As Object, ByVal e As ColumnHeaderCustomDrawEventArgs)
    If e.Column Is _Column Then
        e.Info.Caption = String.Empty

winforms-grid-custom-button-in-column-header/VB/WindowsApplication3/ColumnHeaderExtender.vb#L118

vb
Private Sub OnCustomDrawColumnHeader(ByVal sender As Object, ByVal e As ColumnHeaderCustomDrawEventArgs)
    If e.Column Is Nothing Then
        Return

See Also

ColumnHeaderCustomDrawEventArgs Class

ColumnHeaderCustomDrawEventArgs Members

DevExpress.XtraGrid.Views.Grid Namespace