次の方法で共有


DataRepeater.AddNew メソッド

追加する新しいDataRepeaterItemDataRepeaterコントロールです。

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

構文

'宣言
Public Sub AddNew
public void AddNew()
public:
void AddNew()
member AddNew : unit -> unit
public function AddNew()

例外

例外 条件
ReadOnlyException

AllowUserToAddItems プロパティが False に設定されている。

解説

このメソッドを使用して、新しい表示DataRepeaterItemの下部に、DataRepeaterコントロールです。 内のコントロールのデータ、DataRepeaterItemで、既定値を指定しない限り、空白になりますが、DataSourceChangedイベントまたは、AddNewメソッドです。

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

次の例で、既定のテキストを設定する方法を示しています、AddNewメソッドです。 含む形式であることを前提としています、Buttonという名前のAddNewButtonと、バインドDataRepeaterという名前のコントロールDataRepeater1を含む、TextBoxという名前のコントロールProductNameTextBoxです。

Private Sub AddNewButton_Click() Handles AddNewButton.Click
    ' Add a new repeater item.
    DataRepeater1.AddNew()
    ' Set the default text.
    DataRepeater1.CurrentItem.Controls("ProductNameTextBox").Text = 
       "New Product" 
End Sub
private void addNewButton_Click(object sender, System.EventArgs e)
{
    // Add a new repeater item.
    dataRepeater1.AddNew();
    // Set the default text.
    dataRepeater1.CurrentItem.Controls["productNameTextBox"].Text = "New Product";
}

.NET Framework セキュリティ

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

参照

関連項目

DataRepeater クラス

Microsoft.VisualBasic.PowerPacks 名前空間

その他の技術情報

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

How to: Disable Adding and Deleting DataRepeater Items