windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-rowobjectcustomdraweventargs.md
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
public int RowHandle { get; }
Public ReadOnly Property RowHandle As Integer
| Type | Description |
|---|---|
| Int32 |
An integer value representing the row handle.
|
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
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
r.Offset(r.Width + CheckboxIndent * 2 - 1, 0);
DrawCheckBox(e.Cache, r, IsGroupRowSelected(e.RowHandle));
e.Handled = true;
}
string summaryText = gridView1.GetGroupSummaryDisplayText(e.RowHandle, summary);
info.GroupText += summaryText;
winforms-grid-display-custom-rows/CS/CustomRowInGrid/CustomRowInGrid/Form1.cs#L108
{
int index = gridView1.GetDataRowHandleByGroupRowHandle(e.RowHandle);
winforms-grid-show-gif-animation-in-row-indicator/VB/DataGridWinApp1/Form1.vb#L34
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
r.Offset(r.Width + CheckboxIndent * 2 - 1, 0)
DrawCheckBox(e.Cache, r, IsGroupRowSelected(e.RowHandle))
e.Handled = True
Dim summaryText As String = gridView1.GetGroupSummaryDisplayText(e.RowHandle, summary)
info.GroupText += summaryText
winforms-grid-display-custom-rows/VB/CustomRowInGrid/Form1.vb#L111
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
RowObjectCustomDrawEventArgs Class