Description:
I program in VB.NET and use the XtraGrid in my application. I need to handle the ButtonClick event of the grid's embedded navigator. However, I cannot find it in the list of the form's controls above the code editor.
Answer:
An event handler must be assigned programmatically. Here is some sample code:
Visual BasicAddHandler GridControl1.EmbeddedNavigator.ButtonClick, AddressOf Grid_EmbeddedNavigator_ButtonClick
...
Private Sub Grid_EmbeddedNavigator_ButtonClick(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.NavigatorButtonClickEventArgs)
' Your code is here...
End Sub
If you program in C#, Visual Studio allows you to create a handler for the GridControl.EmbeddedNavigator.ButtonClick event from the Property Window at design time: Select the grid control on your form, go to the Events tab, expand the GridControl.EmbeddedNavigator property and double click the ButtonClick item.
Sure, you can also create an event handler programmatically in C#:
C#gridControl1.EmbeddedNavigator.ButtonClick += new DevExpress.XtraEditors.NavigatorButtonClickEventHandler(Grid_EmbeddedNavigator_ButtonClick);
...
private void Grid_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e) {
// Your code is here...
}
See Also:
Confirm row deletion when using an embedded navigator
It shows syntax error
Hi Francis,
Would you please clarify what code shows the syntax error? I will update this article ASAP.