Xceed Grid for WinForms v4.3 Documentation
Using the mouse and keyboard events

Welcome to Xceed Grid for WinForms v4.3 > Basic Concepts > Events > Using the mouse and keyboard events

Every visual element in Xceed Grid for WinForms behaves as if it were a separate control. This means that each of these elements can raise the mouse and keyboard events separately and you can therefore handle these events without having to write code to check which object has raised the event.

Mouse and keyboard events

When dealing with mouse and keyboard events, once there are rows in the grid, if these rows contain cells, it is the cells that will raise the mouse and keyboard events. If the row does not have cells, then it is the row that will raise the events. With the mouse and keyboard events, it is easier to think of the grid as a panel containing "child" rows which in turn contain "child" cells. 

You won't get mouse and keyboard events directly from the grid once it contains data, therefore you will need to subscribe to the Click event of each cell of the DataRowTemplate.

VB.NET Copy Code
GridControl1.BeginInit() GridControl1.DataSource = DataSet11
GridControl1.DataMember = "Orders" Dim cell As DataCell

For Each cell In GridControl1.DataRowTemplate.Cells
  AddHandler cell.Click, AddressOf Me.cell_Click
Next cell GridControl1.EndInit()
C# Copy Code
gridControl1.BeginInit(); gridControl1.DataSource = dataSet11;
gridControl1.DataMember = "Orders";

foreach( DataCell cell in gridControl1.DataRowTemplate.Cells )
{  
  cell.Click += new EventHandler( this.cell_Click );
} gridControl1.EndInit();

You can also do this in the Grid Designer (C#), by selecting all the cells on the DataRowTemplate (hold Shift and click on every cell), and entering an event handler in the property grid for the Click event.