public int getAttributeOrder(String theName, ListBox lstBox) { if (lstBox.Items.Count > 0) for (int i = 0; i < lstBox.Items.Count; i++) { if (lstBox.Items[i].ToString().StartsWith(theName + " - ")) { return i; } } return -1; }