Remove Method (ObjectListCommandCollection)
Removes the command with the specified name.
public void Remove(
string s
)
Parameters
- s
The name of the command to remove. This method removes the first command that matches this value in the collection.
Example
The following example demonstrates how to use the Remove method to remove an item from the ObjectListCommandCollection. The Boolean flag is a global variable set elsewhere in the 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");
}
}
See Also
Remove Method (DeviceSpecificChoiceCollection) | Remove Method (MobileListItemCollection) | Remove Method (ObjectListFieldCollection) | Remove Method (StyleSheet)
Applies to: ObjectListCommandCollection Class