[英]Gridview column not changing width size
我無法使此GridView列更改其寬度,我已經嘗試過:
<asp:BoundField DataField="ABC" HeaderText="ABC" SortExpression="ABC" ControlStyle-Width="200%">
或以像素為單位:
<asp:BoundField DataField="ABC" HeaderText="ABC" SortExpression="ABC" ControlStyle-Width="500px">
或者在Boundfield標簽內:
<ItemStyle HorizontalAlign="Center" Width="500px"/>
還嘗試了代碼隱藏:
Protected Sub GridView3_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView3.RowDataBound
e.Row.Cells(7).Width = 500
End Sub
我該如何正確處理?
這是可以完成的。 我正在調整具有屬性的列的大小:Visible = True
Private Sub GridViewColumnsrResize(ByVal aspectratio As Integer, ByVal gv As DataGridView)
Try
Dim col_count As Integer = gv.Columns.Count
For j As Integer = 0 To col_count - 1
If gv.Columns(j).Visible = True Then
gv.Columns(j).Width = gv.Columns(j).Width * aspectratio
End If
Next
Catch ex As Exception
'output ex
End Try
End Sub
我昨天剛剛發布了一個與此類似的問題相關的主題。 簡短的答案是你不能。 如該線程所述(在底部),有一種解決方法:
建議 ,如果你想要的值來在同一行,為要增加寬度,那么你可以試試這個:
像cssClass=gridContainer
cssClass
向您的Gridview
添加一個cssClass
,
在.css
文件中添加:
.gridContainer
{
white-space:nowrap;
}
有關更多選項,請查看空白屬性
我通過為GridView本身設置固定寬度來解決此問題,它可能不是為特定列設置的,但是它在所有GridView列之間共享其寬度,從而擴展了我想擴展的列。
<asp:GridView ID="GridView3" runat="server" DataSourceID="SqlDataSource4" AutoGenerateColumns="False" CssClass="Gridview" Width="800px">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.