会员
众包
新闻
博问
闪存
云市场
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
Visual Studio
博客园
首页
新随笔
联系
订阅
管理
为listbox添加横向scroll bar-----通过div实现
后台代码
Code
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(
!
IsPostBack)
{
int
nItem
=
Convert.ToInt32(ListBox1.Items.Count
*
20
);
ListBox1.Height
=
nItem;
//
Set height depends on the font size.
ListBox1.Width
=
300
;
//
This will ensure the list item won't be shrinked!
}
}
前台代码
Code
<
div id
=
'
hello
'
style
=
"
Z-INDEX: 102; LEFT: 13px; OVERFLOW: auto; WIDTH: 150px; POSITION: absolute; TOP: 62px; HEIGHT: 150px
"
>
<
asp:ListBox ID
=
"
ListBox1
"
runat
=
"
server
"
Width
=
"
150px
"
Height
=
"
150px
"
BorderStyle
=
"
None
"
>
<
asp:ListItem Value
=
"
111111111111111111111111111111111111111111111
"
>
11111111111111111111111111111111111111111111111111111111111
</
asp:ListItem
>
<
asp:ListItem Value
=
"
22222222
"
>
55555555555
</
asp:ListItem
>
<
asp:ListItem Value
=
"
333333333333
"
>
555555555555
</
asp:ListItem
>
<
asp:ListItem Value
=
"
444444444444444
"
>
4444444444444444444
</
asp:ListItem
>
</
asp:ListBox
>
</
div
>
posted @
2009-02-18 21:56
凯
阅读(
641
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告