Remove, méthode (ObjectListCommandCollection)
Supprime la commande qui possède le nom spécifié.
public void Remove(
string s
)
Paramètres
- s
Nom de la commande à supprimer. Cette méthode supprime la première commande de la collection qui correspond à la valeur spécifiée.
Exemple
L'exemple suivant montre comment utiliser la méthode Remove pour supprimer un élément de ObjectListCommandCollection. Le flag Boolean est une variable globale définie ailleurs dans l'application.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Command1 = New ObjectListCommand("Command1Text", "Command1Value")
Command1.Name = "cmd1"
Command2 = New ObjectListCommand("Command2Text", "Command2Value")
Command2.Name = "cmd2"
ObjectList1.Commands.Add(Command1)
ObjectList1.Commands.Add(Command2)
End Sub
Sub SelectCommand(sender As Object, e As ObjectListShowCommandsEventArgs)
If flag Then
ObjectList1.Commands.Remove("cmd2")
Else
ObjectList1.Commands.Remove("cmd1")
End If
End Sub 'SelectCommand
[C#]
public void Page_Load(Object sender, EventArgs e)
{
Command1 = new ObjectListCommand("Command1Text", "Command1Value");
Command1.Name = "cmd1";
Command2 = new ObjectListCommand("Command2Text", "Command2Value");
Command2.Name = "cmd2";
ObjectList1.Commands.Add(Command1);
ObjectList1.Commands.Add(Command2);
}
void SelectCommand(Object sender, ObjectListShowCommandsEventArgs e)
{
if (flag)
{
ObjectList1.Commands.Remove("cmd2");
}
else
{
ObjectList1.Commands.Remove("cmd1");
}
}
Voir aussi
Remove, méthode (DeviceSpecificChoiceCollection) | Remove, méthode (MobileListItemCollection) | Remove, méthode (ObjectListFieldCollection) | Remove, méthode (StyleSheet)
S'applique à : ObjectListCommandCollection, classe