DataRepeaterAddRemoveItemsCancelEventArgs.ItemCount 属性

获取已删除的项的数目。

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

语法

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

属性值

类型:System.Int32
项的计数。

备注

DataRepeater 控件的当前实现,只有一个项目中一次被删除。 因此,此属性将始终返回 1。

示例

下面的示例演示如何移除在 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)