次の方法で共有


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
項目のインデックス。

解説

DeletingItemsUserDeletingItems イベントが DataRepeater のコントロールから DataRepeaterItem を削除する要求が行われた場合に発生します。

Trueへ DataRepeaterAddRemoveItemsCancelEventArgs の cancel パラメーターを設定したりすることによって削除をオーバーライドできます。

次の例に 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)