'Declaration Public Event BeforeRowsDeleted As BeforeRowsDeletedEventHandler
public event BeforeRowsDeletedEventHandler BeforeRowsDeleted
The event handler receives an argument of type BeforeRowsDeletedEventArgs containing data related to this event. The following BeforeRowsDeletedEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Cancel (Inherited from System.ComponentModel.CancelEventArgs) | |
DisplayPromptMsg | Whether to display prompt message. |
Rows | The rows (read-only) |
The rows argument returns a reference to a Rows collection that can be used to retrieve references to the UltraGridRow object or objects being deleted. You can use this reference to access any of the returned collection's properties or methods, as well as the properties or methods of the objects within the collection.
The displaypromptmsg argument enables you to hide the default confirmation message. This argument can be used to display your own dialog.
The cancel argument enables you to programmatically prevent the rows from being deleted. This argument can be used to prevent the user from deleting rows unless a certain condition is met.
This event is generated when rows are to be deleted, either programmatically, or by user interaction. To prevent the user from deleting rows, set the Override's UltraGridOverride.AllowDelete property to False. Rows can be deleted programmatically by invoking either the Delete method or the DeleteSelectedRows method.
The text displayed in the default confirmation dialog can be modified by setting the DialogStrings property.
The AfterRowsDeleted event, which occurs after rows are deleted, is generated after this event, provided cancel is not set to True.
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, _ 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 Then e.Cancel = True End If End Sub
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 = System.Windows.Forms.MessageBox.Show( "Deleting " + e.Rows.Length.ToString( ) + " row(s). Continue ?", "Delete rows?", System.Windows.Forms.MessageBoxButtons.YesNo, 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; }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2