KB Article A66
Visible to All Users

Confirm row deletion when using an embedded navigator

Description:
Confirm row deletion when using an embedded navigator

Answer:
You should use the ButtonClick event of the grid's Navigator. Here is some sample code:

C#
using DevExpress.XtraEditors; private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, NavigatorButtonClickEventArgs e) { if(e.Button.ButtonType == NavigatorButtonType.Remove) { if(MessageBox.Show("Do you want to delete the current row?", "Confirm deletion", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes) e.Handled = true; } }
Visual Basic
AddHandler GridControl1.EmbeddedNavigator.ButtonClick, AddressOf Grid_DataNavigator1_ButtonClick ... Private Sub Grid_DataNavigator1_ButtonClick(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.NavigatorButtonClickEventArgs) If e.Button.ButtonType = DevExpress.XtraEditors.NavigatorButtonType.Remove Then If MessageBox.Show("Do you want to delete the current row?", "Confirm deletion", _ MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) <> DialogResult.Yes Then e.Handled = True End If End If End Sub

See Also:
A147

Comments (2)
KK KK
kostas kousinovalis 1 9 years ago

    I tried your sample and its working but the row its deleted even when i press No

    Sasha (DevExpress Support) 9 years ago

      Hello,
      I created a separate ticket on your behalf for this question: The code snippet from the 'Confirm row deletion when using an embedded navigator' KB article works incorrectly. I will update it as soon as possible.

      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.