# How to disable a listbox

vdrockywang
120 2 4

A listbox have many rows and user can select any row he want

when I am modifying data, how can I disable listbox, let user cannot change the current selected row

delete retag edit

## 7 Replies

526 2 2 9

After getting the selected item, you can disable the listbox using the following method:

setDisabled(boolean disabled)

Then after finishing all your work, you can enable the listbox and set the selected item again, if you need.

vdrockywang
120 2 4

No, I had try this, It didn't work !

I use Listbox.setDisabled(true). But I still can select other row...

Do you really try it and can work ???

Or this is a bug ??? because I had try to Button.setDisabled(true), I really cannot press button, It work correctly as I want.

526 2 2 9

If it didn't work, then you need to disable each and every item in the listbox manually one-by-one.

Get List.getItems() and call setDisabled(true) on each item.

I think it will solve your problem.

vdrockywang
120 2 4

listbox.getItems().setXXX doesn't have setDisabled() method can call.....

I don't know what you mean... you just think ??? do you sure how to resolve this problem ??

vdrockywang
120 2 4

Can this problem be resolved ?

9393 3 7 16
http://www.oxitec.de/


(not tested)

List list = myListbox.getItems();
for (Object object : list) {

// need a casting to Listitem
Listitem item = (Listitem) object;

item.setDisabled(true);
}


best
Stephan

vdrockywang
120 2 4

It real work ! :D
thank you so much.

[hide preview]