DataRepeaterAddRemoveItemsCancelEventArgs 构造函数

初始化 DataRepeaterAddRemoveItemsCancelEventArgs 类的新实例。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
Public Sub New ( _
    index As Integer, _
    count As Integer _
)
public DataRepeaterAddRemoveItemsCancelEventArgs(
    int index,
    int count
)
public:
DataRepeaterAddRemoveItemsCancelEventArgs(
    int index, 
    int count
)
new : 
        index:int * 
        count:int -> DataRepeaterAddRemoveItemsCancelEventArgs
public function DataRepeaterAddRemoveItemsCancelEventArgs(
    index : int, 
    count : int
)

参数

备注

,发出请求从 DataRepeater 控件时,删除 DataRepeaterItemDeletingItemsUserDeletingItems 事件发生。

可以通过设置 DataRepeaterAddRemoveItemsCancelEventArgs 的 cancel 参数重写该删除到 True。

示例

下面的示例演示如何移除在 DeletingItems 事件处理程序的一个删除。

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

.NET Framework 安全性

请参见

参考

DataRepeaterAddRemoveItemsCancelEventArgs 类

Microsoft.VisualBasic.PowerPacks 命名空间

DeletingItems

UserDeletingItems

其他资源

DataRepeater 控件简介 (Visual Studio)

如何:禁止添加和删除 DataRepeater 项 (Visual Studio)