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 控制項時, DataRepeaterItem 的 DeletingItems 和 UserDeletingItems 事件發生。
您可以藉由將 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 命名空間