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.
The following events can be raised by Xceed Grid for WinForms:
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.
Raised after a data row has been created in order to group it.
ValidationError events
Cell, DataRow, and InsertionRow
Raised by the AddNew or EndEdit methods when the value of a cell or one of the cells in a DataRow or InsertionRow does not pass the validation process.
Raised when the different parts of the spreadsheet being exported are being written.
Keep in mind that you should subscribe only to the necessary events to avoid needlessly decreasing performance.
Delegates
Each event has a corresponding delegate that is used to subscribe to the event. To subscribe, a new instance of the appropriate delegate class must be created and assigned to the corresponding event. In the constructor of the delegate class, we pass the name of the method that will handle the event(s) we are subscribing to.
VB.NET
Copy Code
Dim grid As New GridControl() AddHandler grid.AddingDataRow, AddressOf Me.Grid_AddingDataRow
C#
Copy Code
GridControl grid = new GridControl(); grid.AddingDataRow += new AddingDataRowEventHandler( this.grid_AddingDataRow );
The declaration of the event handler must have the same parameters as the EventHandler delegate declaration. The first parameter is the source of the event and the second is an argument class.
VB.NET
Copy Code
Private Sub grid_AddingDataROw( ByVal sender As Object, ByVal e As AddingDataRowEventArgs ) End Sub
C#
Copy Code
private void grid_AddingDataRow( object sender, AddingDataRowEventArgs e ){}