-
FEATURED COMPONENTS
First time here? Check out the FAQ!
各位好:我想实现从左 Listbox select1中 点击“右移” 将选中项 移动到Listbox select2中,移动过后删除原Listbox select1中的项,
但是以下代码只能实现移动,不能删除原来项,不知为何?非常感谢
<hbox>
<listbox id="select1" mold="select" rows="5" width="150px"/>
<vbox>
<button id="right_move" label="右移" width="25px" onClick="add.right_move();" />
</vbox>
<listbox id="select2" mold="select" rows="5" width="150px"/>
</hbox>
public boolean left_move() throws InterruptedException{
Mw tt = (Mw)((Listbox)this.getFellow("select1")).getSelectedItem().getValue() ;
Listitem li = new Listitem();
li.setValue(tt);
Listcell lc = new Listcell(tt.getNAME());
lc.setValue(tt.getID());
li.appendChild(lc);
Listbox select_2 = (Listbox) this.getFellow("select2") ;
select_2.appendChild(li);
Listbox select_1 = (Listbox) this.getFellow("select1") ;
select_1.removeChild(li);
return true;
}
直接这样即可
select2.appendChild(select1.getSelectedItem());
或者
select1.getSelectedItem().setParent(select2);
<hbox> <listbox id="select1" mold="select" rows="5" width="150px"> <listitem label="11"></listitem> <listitem label="12"></listitem> </listbox> <vbox> <button id="right_move" label="右移" width="25px"> <attribute name="onClick"> select1.getSelectedItem().setParent(select2); //select2.appendChild(select1.getSelectedItem()); </attribute> </button> </vbox> <listbox id="select2" mold="select" rows="5" width="150px"> <listitem label="21"></listitem> <listitem label="22"></listitem> </listbox> </hbox>
Asked: 2009-12-22 00:26:49 +0800
Seen: 298 times
Last updated: Dec 22 '09