Share via


DataRepeaterAddRemoveItemsCancelEventArgs Class

Provides data for the DeletingItems and UserDeletingItems events.

Inheritance Hierarchy

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

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

Syntax

'Declaration
Public Class DataRepeaterAddRemoveItemsCancelEventArgs _
    Inherits CancelEventArgs
public class DataRepeaterAddRemoveItemsCancelEventArgs : CancelEventArgs
public ref class DataRepeaterAddRemoveItemsCancelEventArgs : public CancelEventArgs
type DataRepeaterAddRemoveItemsCancelEventArgs =  
    class 
        inherit CancelEventArgs 
    end
public class DataRepeaterAddRemoveItemsCancelEventArgs extends CancelEventArgs

The DataRepeaterAddRemoveItemsCancelEventArgs type exposes the following members.

Constructors

  Name Description
Public method DataRepeaterAddRemoveItemsCancelEventArgs Initializes a new instance of the DataRepeaterAddRemoveItemsCancelEventArgs class.

Top

Properties

  Name Description
Public property Cancel Gets or sets a value indicating whether the event should be canceled. (Inherited from CancelEventArgs.)
Public property ItemCount Gets the number of items being deleted.
Public property ItemIndex Gets the index of the item that is being deleted.

Top

Methods

  Name Description
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as the default hash function. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

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 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
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.");
    }
}   

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

Reference

Microsoft.VisualBasic.PowerPacks Namespace

DeletingItems

UserDeletingItems

Other Resources

Introduction to the DataRepeater Control (Visual Studio)

How to: Disable Adding and Deleting DataRepeater Items (Visual Studio)