共用方式為


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)

HOW TO:停用加入和刪除 DataRepeater 項目 (Visual Studio)