Back to Devexpress

RowObjectCustomDrawEventArgs.RowHandle Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-rowobjectcustomdraweventargs.md

latest6.3 KB
Original Source

RowObjectCustomDrawEventArgs.RowHandle Property

Gets the handle of the row whose corresponding element is being painted.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
public int RowHandle { get; }
vb
Public ReadOnly Property RowHandle As Integer

Property Value

TypeDescription
Int32

An integer value representing the row handle.

|

Remarks

When handling the GridView.CustomDrawRowPreview event, the RowHandle property returns the data row handle. This handle identifies the row whose preview section is being painted. When handling either the GridView.CustomDrawGroupRow or GridView.CustomDrawRowFooter event, the RowHandle property returns the group row handle that identifies the painted element. Finally, when handling the GridView.CustomDrawFooter event, the property returns the GridControl.InvalidRowHandle field value. This is becauset the View footer doesn’t correspond to any row.

Use the RowHandle property to identify the painted element and obtain row data. In this case, you can implement conditional painting based on the element position or the row’s data.

The following code snippets (auto-collected from DevExpress Examples) contain references to the RowHandle 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-show-gif-animation-in-row-indicator/CS/DataGridWinApp1/Form1.cs#L37

csharp
GridView view = (GridView)sender;
if ( e.RowHandle != view.FocusedRowHandle || !view.IsDataRow(e.RowHandle) || imgToDraw == null )
    return;

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

csharp
r.Offset(r.Width + CheckboxIndent * 2 - 1, 0);
DrawCheckBox(e.Cache, r, IsGroupRowSelected(e.RowHandle));
e.Handled = true;

winforms-grid-conditionally-hide-summaries-from-group-rows/CS/ConditionallyHideSumsInGroupRows/Form1.cs#L44

csharp
}
string summaryText = gridView1.GetGroupSummaryDisplayText(e.RowHandle, summary);
info.GroupText += summaryText;

winforms-grid-display-custom-rows/CS/CustomRowInGrid/CustomRowInGrid/Form1.cs#L108

csharp
{
    int index = gridView1.GetDataRowHandleByGroupRowHandle(e.RowHandle);

winforms-grid-show-gif-animation-in-row-indicator/VB/DataGridWinApp1/Form1.vb#L34

vb
Dim view As GridView = DirectCast(sender, GridView)
If e.RowHandle <> view.FocusedRowHandle OrElse Not view.IsDataRow(e.RowHandle) OrElse imgToDraw Is Nothing Then
    Return

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

vb
r.Offset(r.Width + CheckboxIndent * 2 - 1, 0)
DrawCheckBox(e.Cache, r, IsGroupRowSelected(e.RowHandle))
e.Handled = True

winforms-grid-conditionally-hide-summaries-from-group-rows/VB/ConditionallyHideSumsInGroupRows/Form1.vb#L44

vb
Dim summaryText As String = gridView1.GetGroupSummaryDisplayText(e.RowHandle, summary)
info.GroupText += summaryText

winforms-grid-display-custom-rows/VB/CustomRowInGrid/Form1.vb#L111

vb
Private Sub gridView1_CustomDrawGroupRow(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs) Handles gridView1.CustomDrawGroupRow
    Dim index As Integer = gridView1.GetDataRowHandleByGroupRowHandle(e.RowHandle)

See Also

Rows

RowObjectCustomDrawEventArgs Class

RowObjectCustomDrawEventArgs Members

DevExpress.XtraGrid.Views.Base Namespace