DataRepeaterAddRemoveItemsCancelEventArgs.ItemIndex 属性

获取已删除项的索引。

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

语法

声明
Public ReadOnly Property ItemIndex As Integer
public int ItemIndex { get; }
public:
property int ItemIndex {
    int get ();
}
member ItemIndex : int
function get ItemIndex () : int

属性值

类型:System.Int32
项的索引。

备注

,发出请求从 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)