Back to Devexpress

GridView.RowClick Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-12eb28c9.md

latest7.8 KB
Original Source

GridView.RowClick Event

Allows you to respond to row clicks. The event will not fire when data editing is enabled and the ColumnViewOptionsBehavior.EditorShowMode property is set to MouseDown (and to Default , if multiple row selection is disabled).

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[DXCategory("Action")]
public event RowClickEventHandler RowClick
vb
<DXCategory("Action")>
Public Event RowClick As RowClickEventHandler

Event Data

The RowClick event's data class is RowClickEventArgs. The following properties provide information specific to this event:

PropertyDescription
ButtonGets which mouse button was pressed. Inherited from MouseEventArgs.
ClicksGets the number of times the mouse button was pressed and released. Inherited from MouseEventArgs.
DeltaGets a signed count of the number of detents the mouse wheel has rotated, multiplied by the WHEEL_DELTA constant. A detent is one notch of the mouse wheel. Inherited from MouseEventArgs.
HandledGets or sets whether this event should be forwarded to the control’s parent container. Inherited from HandledMouseEventArgs.
HitInfoGets an object that identifies the clicked element.
IsHMouseWheelThis member supports the internal infrastructure, and is not intended to be used directly from your code. Inherited from DXMouseEventArgs.
IsMouseEventGets whether these event arguments provide data for the MouseUp, MouseDown, and MouseMove events. Inherited from DXMouseEventArgs.
LocationGets the location of the mouse during the generating mouse event. Inherited from MouseEventArgs.
RowHandleGets the handle of the clicked row.
XGets the x-coordinate of the mouse during the generating mouse event. Inherited from MouseEventArgs.
YGets the y-coordinate of the mouse during the generating mouse event. Inherited from MouseEventArgs.

The event data class exposes the following methods:

MethodDescription
GetMouseArgs(Control, EventArgs)Converts the MouseEventArgs object passed as a parameter to a DXMouseEventArgs object. Inherited from DXMouseEventArgs.
GetMouseArgs(MouseEventArgs, Boolean)Inherited from DXMouseEventArgs.
GetMouseArgs(MouseEventArgs)Converts the MouseEventArgs object passed as a parameter to a DXMouseEventArgs object. Inherited from DXMouseEventArgs.
Sync()For internal use. Inherited from DXMouseEventArgs.

Remarks

The RowClick event fires when clicking on any element of a grid row (cell, cell border, row indicator, etc).

The RowClick event will not fire when clicking on a row cell if data editing is enabled and the ColumnViewOptionsBehavior.EditorShowMode property is set to MouseDown (and to Default , if multiple row selection is disabled).

The code sample below illustrates how to use the RowClick event to copy a column’s value into a TextEdit control.

csharp
gridView1.Columns["ID"].View.OptionsBehavior.EditorShowMode = EditorShowMode.MouseUp;
gridView1.RowClick += gridView1_RowClick;

private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
{
    textEdit1.EditValue = (sender as GridView).GetFocusedRowCellValue("ID");
}
vb
Private gridView1.Columns("ID").View.OptionsBehavior.EditorShowMode = EditorShowMode.MouseUp
Private gridView1.RowClick += AddressOf gridView1_RowClick

Private Sub gridView1_RowClick(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.RowClickEventArgs)
            textEdit1.EditValue = (TryCast(sender, GridView)).GetFocusedRowCellValue("ID")
End Sub

See Also

MultiSelect

FocusedColumnChanged

FocusedRowChanged

GridView Class

GridView Members

DevExpress.XtraGrid.Views.Grid Namespace