Share via


DataRepeaterAddRemoveItemsCancelEventArgs Class

 

Provides data for the DeletingItems and UserDeletingItems events.

Namespace:   Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Inheritance Hierarchy

System.Object
  System.EventArgs
    System.ComponentModel.CancelEventArgs
      Microsoft.VisualBasic.PowerPacks.DataRepeaterAddRemoveItemsCancelEventArgs

Syntax

public class DataRepeaterAddRemoveItemsCancelEventArgs : CancelEventArgs
public ref class DataRepeaterAddRemoveItemsCancelEventArgs : CancelEventArgs
type DataRepeaterAddRemoveItemsCancelEventArgs = 
    class
        inherit CancelEventArgs
    end
Public Class DataRepeaterAddRemoveItemsCancelEventArgs
    Inherits CancelEventArgs

Constructors

Name Description
System_CAPS_pubmethod DataRepeaterAddRemoveItemsCancelEventArgs(Int32, Int32)

Initializes a new instance of the DataRepeaterAddRemoveItemsCancelEventArgs class.

Properties

Name Description
System_CAPS_pubproperty Cancel

(Inherited from CancelEventArgs.)

System_CAPS_pubproperty ItemCount

Gets the number of items being deleted.

System_CAPS_pubproperty ItemIndex

Gets the index of the item that is being deleted.

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Remarks

The DeletingItems and UserDeletingItems events occur when a request is made to delete a DataRepeaterItem from a DataRepeater control.

You can override the deletion by setting the cancel parameter of the DataRepeaterAddRemoveItemsCancelEventArgs to True.

Examples

The following example demonstrates how to cancel a deletion in the DeletingItems event handler.

private void DataRepeater1_DeletingItems(object sender, 
    Microsoft.VisualBasic.PowerPacks.DataRepeaterAddRemoveItemsCancelEventArgs e)
{
    // Check whether the user is a supervisor.

    ClientRolePrincipal rolePrincipal =
        System.Threading.Thread.CurrentPrincipal
        as ClientRolePrincipal;

    if (rolePrincipal.IsInRole("supervisor") == false)
    {
        e.Cancel = true;
        MessageBox.Show("You are not authorized to delete.");
    }
}   
Private Sub DataRepeater1_DeletingItems(
    ByVal sender As Object, 
    ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterAddRemoveItemsCancelEventArgs
  ) Handles DataRepeater1.DeletingItems

    ' Check whether the user is a supervisor.
    If My.User.IsInRole("Supervisor") = False Then
        ' Cancel the deletion and display a message.
        e.Cancel = True
        MsgBox("You are not authorized to delete.")
    End If
End Sub

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

DeletingItems
UserDeletingItems
Microsoft.VisualBasic.PowerPacks Namespace
Introduction to the DataRepeater Control (Visual Studio)
How to: Disable Adding and Deleting DataRepeater Items (Visual Studio)

Return to top