后台代码
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>
转载于:https://www.cnblogs.com/kaiwind/archive/2009/02/18/1393506.html
转载请注明原文地址: https://win8.8miu.com/read-1482900.html