共用方式為


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 with get
function get ItemIndex () : int

屬性值

類型: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)