次の方法で共有


DataRepeater.AllowUserToAddItems プロパティ

取得またはユーザーが新しい行を追加できるかどうかを決定する値を設定、DataRepeater実行時にします。

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

構文

'宣言
Public Property AllowUserToAddItems As Boolean
public bool AllowUserToAddItems { get; set; }
public:
property bool AllowUserToAddItems {
    bool get ();
    void set (bool value);
}
member AllowUserToAddItems : bool with get, set
function get AllowUserToAddItems () : boolean 
function set AllowUserToAddItems (value : boolean)

プロパティ値

型 : Boolean
trueユーザーが行の行が追加できる場合は、それ以外の場合falseです。既定値は、true です。

解説

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 名前空間

その他の技術情報

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

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