0

listbox显示项目的问题

asked 2009-09-28 09:02:22 +0800

lydia gravatar image lydia
90

一个listbox里面有很多项,并且有滚动条,初始化时选中了最后一项,但是初始化显示时看不到最后一项被选中了,怎么把初始化时的显示定位到最后,也就是滚动条定位到列表的底部。
很直观的问题,却很难用语言描述,不知道我说清楚了没有,知道的朋友还烦请指导一下哦

delete flag offensive retag edit

21 Replies

Sort by » oldest newest

answered 2009-09-29 01:09:29 +0800

adam4891288 gravatar image adam4891288
657 1 5

updated 2009-09-29 01:09:42 +0800

可以通過設置focus來實現吧。

Listcell lc = new Listcell();
lc.focus();

link publish delete flag offensive edit

answered 2009-09-30 02:35:59 +0800

lydia gravatar image lydia
90

我试了focus这方法不管用啊,你试过可以吗

link publish delete flag offensive edit

answered 2009-09-30 05:49:27 +0800

adam4891288 gravatar image adam4891288
657 1 5

剛才測試了下,是有用的。

<listbox id="list" model="${strset}" width="200px" height="100px" onCreate="last.focus();">
	<listhead>
		<listheader label="Load on Demend" sort="auto" />
	</listhead>
	<listitem>
		<listcell label="1"></listcell>
	</listitem>
	<listitem>
		<listcell label="1"></listcell>
	</listitem>
	<listitem>
		<listcell label="1"></listcell>
	</listitem>
	<listitem>
		<listcell label="1"></listcell>
	</listitem>
	<listitem>
		<listcell label="1"></listcell>
	</listitem>
	<listitem>
		<listcell label="1"></listcell>
	</listitem>
	<listitem>
		<listcell label="1"></listcell>
	</listitem>
	<listitem>
		<listcell label="1"></listcell>
	</listitem>
	<listitem>
		<listcell id="last" label="14"></listcell>
	</listitem>
</listbox>

link publish delete flag offensive edit

answered 2009-09-30 08:11:33 +0800

lydia gravatar image lydia
90

看到了,那必须在onCreate时候才有效了,Create完后再focus就没用了
我现在需要Create完再把滚动条拉到后面,有办法吗

link publish delete flag offensive edit

answered 2009-09-30 09:07:58 +0800

adam4891288 gravatar image adam4891288
657 1 5

那你具體是想要在什麽時候focus呢?
總要觸發一個事件來調用這個focus吧?

link publish delete flag offensive edit

answered 2009-09-30 09:09:46 +0800

lydia gravatar image lydia
90

就是把数据放在列表后,setModel后的

link publish delete flag offensive edit

answered 2009-09-30 09:11:01 +0800

lydia gravatar image lydia
90

或者是往列表添加item的时候

link publish delete flag offensive edit

answered 2009-09-30 09:11:37 +0800

lydia gravatar image lydia
90

这时候listbox都已经完成create了

link publish delete flag offensive edit

answered 2009-09-30 09:13:11 +0800

adam4891288 gravatar image adam4891288
657 1 5

剛才測試了下,如果使用一個Button的onClick事件來調用focus()仍然是可以的。
而且,onCreate其實就是Create完畢才把滾動條拉到後面的。

link publish delete flag offensive edit

answered 2009-09-30 09:19:11 +0800

adam4891288 gravatar image adam4891288
657 1 5

剛才測試了setModel的方式加入Listitem,仍然使用onCreate調用focus(),是可以達到目的的。

listbox.getLastChild().getFirstChild().focus();

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-09-28 09:02:22 +0800

Seen: 827 times

Last updated: Oct 13 '09

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