BindingSource.AllowNew プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > BindingSource.AllowNew プロパティの意味・解説 

BindingSource.AllowNew プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

AddNew メソッド使用してリストに項目を追加できるかどうかを示す値を取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Overridable Property
 AllowNew As Boolean
Dim instance As BindingSource
Dim value As Boolean

value = instance.AllowNew

instance.AllowNew = value
public virtual bool AllowNew { get;
 set; }
/** @property */
public boolean get_AllowNew ()

/** @property */
public void set_AllowNew (boolean value)

プロパティ
AddNew使用してリストに項目を追加できる場合trueそれ以外場合false

例外例外
例外種類条件

InvalidOperationException

List プロパティ表される基底リスト固定サイズまたは読み取り専用であるにもかかわらず、このプロパティtrue設定されています。

MissingMethodException

基底リストの型に既定コンストラクタがないにもかかわらず、このプロパティtrue設定され、AddingNew イベント処理されていません。

解説解説

AllowNew プロパティ既定値は、基底データ ソースの型によって異なります基底リストに、IBindingList インターフェイス実装されている場合、このプロパティ基底リスト代行されますそれ以外場合で、基底リスト次の特性うちいずれかを備えている場合、このプロパティfalse返します

メモメモ

このプロパティの値を設定すると、取得側は、以降呼び出し基底リスト参照しません。代わりに、ResetAllowNew メソッド呼び出されるまで、以前設定された値を返すだけです。

このプロパティ設定すると、ListChangedEventArgs.ListChangedType が ListChangedType.Reset に設定された ListChanged イベント発生します

AllowNew プロパティtrue設定するとき、基底リストの型に既定コンストラクタない場合は、AddingNew イベント処理して適切な型を作成する必要があります

使用例使用例

次のコード例では、BindingSource コンポーネントAllowNew プロパティ使用してユーザーBindingSource コンポーネント基底リストに項目を追加できるようにする方法示します。このプロパティtrue設定すると、バインドされた DataGridView コントロール新しレコード用の行が表示されます。

Public Sub New() 
    ' Set up the form.
    Me.Size = New Size(800, 800)
    AddHandler Me.Load, AddressOf
 Form1_Load
    
    ' Set up the DataGridView control.
    Me.customersDataGridView.AllowUserToAddRows = True
    Me.customersDataGridView.Dock = DockStyle.Fill
    Me.Controls.Add(customersDataGridView)
    
    ' Add the StatusBar control to the form.
    Me.Controls.Add(status)
    
    ' Allow the user to add new items.
    Me.customersBindingSource.AllowNew = True
    
    ' Attach the BindingSource to the DataGridView.
    Me.customersDataGridView.DataSource = Me.customersBindingSource

End Sub
public Form1()
{
    // Set up the form.
    this.Size = new Size(800, 800);
    this.Load += new EventHandler(Form1_Load);

    // Set up the DataGridView control.
    this.customersDataGridView.AllowUserToAddRows = true;
    this.customersDataGridView.Dock = DockStyle.Fill;
    this.Controls.Add(customersDataGridView);

    // Add the StatusBar control to the form.
    this.Controls.Add(status);

    // Allow the user to add new items.
    this.customersBindingSource.AllowNew = true;

    // Attach an event handler for the AddingNew event.
    this.customersBindingSource.AddingNew +=
        new AddingNewEventHandler(customersBindingSource_AddingNew);

    // Attach an eventhandler for the ListChanged event.
    this.customersBindingSource.ListChanged +=
        new ListChangedEventHandler(customersBindingSource_ListChanged);

    
    // Attach the BindingSource to the DataGridView.
    this.customersDataGridView.DataSource =
        this.customersBindingSource;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingSource クラス
BindingSource メンバ
System.Windows.Forms 名前空間
NewObject
ResetAllowNew
List
BindingSource.AllowEdit プロパティ
AllowRemove
EndEdit
CancelEdit
AddNew


このページでは「.NET Framework クラス ライブラリ リファレンス」からBindingSource.AllowNew プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBindingSource.AllowNew プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBindingSource.AllowNew プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

BindingSource.AllowNew プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



BindingSource.AllowNew プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS