Infragistics(R) NetAdvantage(R) Windows Forms
BeforeRowsDeletedEventHandler Delegate
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace : BeforeRowsDeletedEventHandler Delegate

delegate for handling event that is fired before rows are deleted


Visual Basic (Declaration) 
Public Delegate Sub BeforeRowsDeletedEventHandler( _
   ByVal sender As Object, _
   ByVal e As BeforeRowsDeletedEventArgs _
public delegate void BeforeRowsDeletedEventHandler( 
   object sender,
   BeforeRowsDeletedEventArgs e




The following sample code uses BeforeRowsDeleted event to display a custom message box to prompt the user before deleting rows.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub UltraGrid1_BeforeRowsDeleted(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventArgs) Handles ultraGrid1.BeforeRowsDeleted

      ' Stop the grid from displaying it's message box.
      e.DisplayPromptMsg = False

      ' Display our own custom message box.
      Dim result As DialogResult = System.Windows.Forms.MessageBox.Show( _
              "Deleting " & e.Rows.Length.ToString() & " row(s). Continue ?", _
              "Delete rows?", _
              System.Windows.Forms.MessageBoxButtons.YesNo, _

      ' If the user clicked No on the message box, cancel the deletion of rows.
      If System.Windows.Forms.DialogResult.No = result Then
          e.Cancel = True
      End If

  End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_BeforeRowsDeleted(object sender, Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventArgs e)

	// Stop the grid from displaying it's message box.
	e.DisplayPromptMsg = false;
	// Display our own custom message box.
	System.Windows.Forms.DialogResult result =
		"Deleting " + e.Rows.Length.ToString( ) + " row(s). Continue ?",
		"Delete rows?", 
		System.Windows.Forms.MessageBoxIcon.Question );
	// If the user clicked No on the message box, cancel the deletion of rows.
	if ( System.Windows.Forms.DialogResult.No == result )
		e.Cancel = true;


See Also