Xceed Grid for WinForms v4.3 Documentation
Overview - Events
Welcome to Xceed Grid for WinForms v4.3 > Grid Overview > Overview - Events
Overview - Grid elementsOverview - Providing, editing and displaying data

An event is a message raised by an object to signal the occurrence of an action. In order to receive event notifications, a caller must subscribe to the desired events. 

Both the grid and its grid elements can raise various events. The most commonly used ones are: the AddingDataRow event which is raised when a new data row is about to be added to the grid, the DataRowsChanged and SiblingDataRowsChanged events which are raised when modifications are made to the content of a cell in a data row and when a data row (or sibling data row ) is added or removed from the grid, the EnteringEdit event which is raised before editing a cell, the GroupAdded event which is raised when a group has been added to the grid, the LeavingEdit event which is raised after a cell has been edited, the QueryGroupKeys event which is raised after a data row has been created in order to group it, the ValidationError events which are raised when the value of a cell does not pass the validation process and the ValueChanging event which is raised when a cell's value is being changed. 

Every property also has a corresponding "PropertyChanged" event which is raised when the value of a grid element's property changes to provide notification that the property has been modified. 

In order to keep optimal performance levels, only the necessary events should be subscribed to. For more information regarding of each these events, jump to the Basic Concepts/Events topic.

Mouse and keyboard events

Every element in the grid 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. 

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. For more information on mouse and keyboard events, jump to the Using the mouse and keyboard events topic.

Subscribing to events

Subscribing to the events of grid elements (and the grid!) is done in the same way as, for example, subscribing to a button's Click event. This means that any grid element (with the exception of columns and groups) can have a specific handler for their particular events, or event handlers can be shared among multiple grid elements. 

As mentioned in the previous section, once the grid is populated with data, it will no longer raise the mouse and keyboard events. Therefore, in order to subscribe to the "grid's" mouse and keyboard events, you will need to subscribe to each cell's mouse and keyboard events instead. 

The best way to subscribe to the events of each cell in the grid is to subscribe to the events of each cell in the DataRowTemplate. If your grid is data bound, in order to subscribe to the events of each cell in the DataRowTemplate, you will need to bind the grid (set the DataSource/ DataMember properties or call the SetDataBinding method) between calls to the grid's BeginInit and EndInit methods. If you are providing data manually (unbound mode), then the columns need to be added to the grid before subscribing to the events of each cell in the DataRowTemplate. Once you have subscribed to the events, you can then add your data. For more information on how to subscribe to the events of each cell, jump to the How to subscribe to the events of each cell topic.