KB Article A147
Visible to All Users

How to assign a ButtonClick event handler to the grid's embedded navigator

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 Basic
AddHandler 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

Comments (2)

    It shows syntax error

    Alisher (DevExpress Support) 10 years ago

      Hi Francis,

      Would you please clarify what code shows the syntax error? I will update this article ASAP.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.