How to select item that starts with a string

I’m trying to select an item from a combobox in a windows rich client application. The items are formatted in the list as “Code - Description”. I’d like to select the item by code only, rather than needing to know the description also.

Is this possible in a reasonably simple way?


I believe you can do this by first getting all the items in the list, then either filtering the list to the item you want or looping though each item with an if condition. After you know the item, you can use that as a variable in the Select Item activity.

Getting all the items in the combobox is not fresh on my mind but if you look here you might find an answer: Get all items of a list box

If you can store those in an array, then you can use the .Where()
arrList.Where(Function(x) x.StartsWith(“Code”)).ToArray(0)

Then use that as your input for the Select Item.

EDIT: You might also look at the reply about using the Get Attribute Property because if you can use the aaname with “Code*” having a wildcard then it will retrieve only the text of that item which you can use instead of an array.

Hope this helps. Thanks.


Thank you, this definitely got me pointed in the right direction. I needed to grab the “text” attribute instead of “aaname”, but your answer was what I needed. That said, I do wish this was configurable on the Select Item activity itself :confused: