Proprietà DataRepeater.AllowUserToAddItems
Ottiene o imposta un valore che determina se gli utenti possono aggiungere una nuova riga a un oggetto DataRepeater in fase di esecuzione.
Spazio dei nomi: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Sintassi
'Dichiarazione
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)
Valore proprietà
Tipo: Boolean
true se l'utente può aggiungere righe; in caso contrario, false.Il valore predefinito è true.
Note
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.
Esempi
L'esempio di codice riportato di seguito viene illustrato come disabilitare Aggiungi pulsante quando il AllowUserToAddItems è impostata su False. Si presuppone che si disponga di un modulo che contiene un DataRepeater controllo denominato DataRepeater1 e BindingNavigator controllo denominato 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;
}
}
Sicurezza di .NET Framework
- Attendibilità totale per il chiamante immediato. Impossibile utilizzare questo membro in codice parzialmente attendibile. Per altre informazioni, vedere Utilizzo di librerie da codice parzialmente attendibile.
Vedere anche
Riferimenti
Spazio dei nomi Microsoft.VisualBasic.PowerPacks
Altre risorse
Introduzione al controllo DataRepeater (Visual Studio)
Procedura: disabilitare l'aggiunta e l'eliminazione di elementi DataRepeater (Visual Studio)