如何在 ASP.NET 2.0 中控制 gridview 控件的列宽?
Billy
问问题
36228 次
4 回答
8
You can use the HeaderStyle-Width, ItemStyle-Width or FooterStyle-Width properties. These can be applied to all the columns or per-column basis.
<asp:GridView ID="GridView1" runat="server">
<HeaderStyle Width="10%" />
<RowStyle Width="10%" />
<FooterStyle Width="10%" />
<Columns>
<asp:BoundField HeaderText="Name" DataField="LastName"
HeaderStyle-Width="10%" ItemStyle-Width="10%"
FooterStyle-Width="10%" />
</Columns>
</asp:GridView>
于 2009-02-13T14:31:24.023 回答
3
我使用列的标题样式来做到这一点:
<asp:BoundField HeaderText="Name" DataField="LastName">
<HeaderStyle Width="20em" />
</asp:BoundField>
于 2008-11-21T19:19:27.687 回答
3
这是以编程方式执行此操作的 C# 代码:
columnName.ItemStyle.Width = Unit.Percentage(someDouble);
于 2012-02-09T16:56:34.770 回答
0
Gridview.Columns[1].ItemStyle.Width = 100;
这将以像素为单位设置。
于 2013-08-09T11:45:29.767 回答