eEcho blog

is een halte van de gedachte

Get ListBox Value’s Index getListBoxIndexByValue

Here is a method used to find the value’s index, so then you can setSelected for listbox by value.

/**
* get list box value’s index
* @param lb ListBox - what listbox are you looking for value’s index
* @param SelectedValue - what is the value’s index your looking for
* @return
*/
public int getListBoxIndexByValue(ListBox lb, String SelectedValue) {

if (SelectedValue == null) {
return 0;
}

for (int i = 0; i < lb.getItemCount(); i++) {
String CompareValue = lb.getValue(i);
if (SelectedValue.equals(CompareValue)) {
return i;
}
}
return 0;
}

Add A Comment

You must be logged in to post a comment.

Home | info@eecho.info | Voorwaarden | Blog