次の方法で共有


DataRepeater.AllowUserToAddItemsChanged イベント

AllowUserToAddItems プロパティが変更されたときに発生します。

名前空間:  Microsoft.VisualBasic.PowerPacks
アセンブリ:  Microsoft.VisualBasic.PowerPacks.Vs (Microsoft.VisualBasic.PowerPacks.Vs.dll 内)

構文

'宣言
Public Event AllowUserToAddItemsChanged As EventHandler
public event EventHandler AllowUserToAddItemsChanged
public:
 event EventHandler^ AllowUserToAddItemsChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
member AllowUserToAddItemsChanged : IEvent<EventHandler,
    EventArgs>
JScript では、イベントは使用できません。

解説

When the AllowUserToAddItems property is set to True, users can add a new row by clicking the BindingNavigatorAddNewItem ToolStripButton on the BindingNavigator control, or by pressing CTRL+N when a DataRepeaterItem has focus.

When the AllowUserToAddItems property is set to False, the CTRL+N keyboard function is disabled, but the BindingNavigatorAddNewItem ToolStripButton is still enabled. If you want to prevent users from adding rows, you should also disable or remove the BindingNavigatorAddNewItem ToolStripButton on the BindingNavigator control.

イベントを処理する方法の詳細については、次を参照してください。イベントの処理と発生です。

次のコード例には無効にする方法を示しています、追加ボタン、AllowUserToAddItemsプロパティに設定されてFalseです。 含む形式であることを前提としています、DataRepeaterという名前のコントロールDataRepeater1とBindingNavigatorという名前のコントロールProductsBindingSourceです。

Private Sub DataRepeater1_AllowUserToAddItemsChanged(
    ) Handles DataRepeater1.AllowUserToAddItemsChanged

    ' If this event occurs during form initialization, exit. 
    If Me.IsHandleCreated = False Then Exit Sub 
    ' If AllowUserToAddItems is False. 
    If DataRepeater1.AllowUserToAddItems = False Then 
        ' Disable the Add button.
        BindingNavigatorAddNewItem.Enabled = False 
        ' Disable the BindingSource property.
        ProductsBindingSource.AllowNew = False 
    Else 
        ' Otherwise, enable the Add button.
        BindingNavigatorAddNewItem.Enabled = True 
    End If 
End Sub
private void dataRepeater1_AllowUserToAddItemsChanged(object sender, System.EventArgs e)
{
    // If this event occurs during form initialization, exit. 
    if (this.IsHandleCreated == false) { return; }
    // If AllowUserToAddItems is False. 
    if (dataRepeater1.AllowUserToAddItems == false)
    // Disable the Add button.
    {
        bindingNavigatorAddNewItem.Enabled = false;
        // Disable the BindingSource property.
        productsBindingSource.AllowNew = false;
    }
    else
    {
        // Otherwise, enable the Add button.
        bindingNavigatorAddNewItem.Enabled = true;
    }
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

DataRepeater クラス

Microsoft.VisualBasic.PowerPacks 名前空間

AllowUserToAddItems

AllowUserToDeleteItems

その他の技術情報

DataRepeater コントロールの概要 (Visual Studio)

方法 : DataRepeater の項目の追加と削除を無効にする (Visual Studio)