Metodo IndexOf (ObjectListCommandCollection)
Restituisce l'indice del comando il cui nome corrisponde alla stringa specificata.
public int IndexOf(
string s
)
Parametri
- s
Una stringa da ricercare nell'insieme.
Valori restituiti
Restituisce l'indice del comando, la cui proprietà Name corrisponde alla stringa specificata dal parametro s. Se nell'insieme non vengono rilevati elementi corrispondenti, il metodo IndexOf restituisce il valore –1.
Esempio
Nell'esempio seguente viene mostrato come utilizzare il metodo IndexOf per recuperare il comando Edit
o Delete
di ObjectListCommandCollection.
Sub ShowTaskDetail(sender As Object, e As ObjectListSelectEventArgs)
'Check conditions to Add or remove Commands in detail view
If ObjectList1.Selection("Editable").Equals("No") Then
ObjectList1.Commands.RemoveAt(ObjectList1.Commands.IndexOf("Edit"))
End If
End Sub
[C#]
void ShowTaskDetail(Object sender, ObjectListSelectEventArgs e)
{
//Check conditions to Add or remove Commands in detailview
if(ObjectList1.Selection["Editable"].Equals("No"))
{
ObjectList1.Commands.RemoveAt(ObjectList1.Commands.IndexOf("Edit"));
}
}
Vedere anche
Metodo IndexOf (IObjectListFieldCollection) | Metodo IndexOf (MobileListItemCollection) | Metodo IndexOf (ObjectListFieldCollection) | Metodo IndexOf (ObjectListItemCollection)
Si applica a: classe ObjectListCommandCollection