DataRepeater.AddNew Method
Adds a new DataRepeaterItem to the DataRepeater control.
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
| Exception | Condition |
|---|---|
| ReadOnlyException | The AllowUserToAddItems property is set to False. |
Use this method to display a new DataRepeaterItem at the bottom of the DataRepeater control. Data for the controls in the DataRepeaterItem will be blank unless a default value is supplied by the DataSourceChanged event or in the AddNew method.
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.
The following example demonstrates how to set default text in the AddNew method. It assumes that you have a form that contains a Button named AddNewButton and a bound DataRepeater control named DataRepeater1 that contains a TextBox control named ProductNameTextBox.
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.