0

右移后删除

asked 2009-12-22 00:26:49 +0800

fzm gravatar image fzm
42 1

各位好:我想实现从左 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;
}

delete flag offensive retag edit

2 Replies

Sort by » oldest newest

answered 2009-12-22 20:15:48 +0800

adam4891288 gravatar image adam4891288
657 1 5

直接这样即可
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>

link publish delete flag offensive edit

answered 2009-12-22 21:00:03 +0800

fzm gravatar image fzm
42 1

非常感谢

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-12-22 00:26:49 +0800

Seen: 298 times

Last updated: Dec 22 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More