Share via


How To: Select a list item directly

This question came up couple of times from internal users -

Given a combo box (or list), I can set SelectedItem (or SelectedItems) property to select a list item. However, how do I do this directly from list item itself i.e. given a list item, how do I select that.

Essentially, folks are looking for Select() API on list item which is not there today in the product.  The good news is this API is available in the utility library that we have released. So if you are using this utility library, you can simply do myListItem.Select(); .

If you are not using this utility library, I recommend taking a look at using it.  There are some really good useful function in there.  If you still don’t want to use it :(, here is how you can achieve the above -

    myComboBox.SelectedItem = myListItem.DisplayText;

where myComboBox is the combo box which has the list item.