Several methods of column width fixing are introduced

  • 2020-06-23 00:08:43
  • OfStack

1, in the edit column, directly set the width of the column! If you don't want the contents of the cell to stretch the cell, add a style
< style > table{table-layout:fixed} < /style > , meaning that each column is fixed to the original style, no change, the excess part is hidden

2. You can set the property of a column below the edit column in gridview < HeaderStyle Width="8%" > < /HeaderStyle > , so you can get what percentage of the screen is displayed

3. You must have set the height attribute of gridview, so you fixed the height of gridview. When the data is insufficient, the height of gridview will not change.
e. Row. Attributes. Add (" style ", "43 px height:"); Set the row height like this
The automatically generated GridView cannot change the column width; it can be set using ItemStyle


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"> 
<Columns> 
<asp:BoundField DataField="id"> 
<ItemStyle Width="100px" /> 
</asp:BoundField> 
</Columns> 
</asp:GridView>

4,
1. GridView-- > Columns---- > HeaderStyle ,GridView-- > Columns---- > ItemStyle - > Height, Width, set the width and height of the column.

2. Set the wrap attribute under the current column to false. It means you can't wrap a line automatically. Step 1 Do a lot of online searches, but find these results are not what you want. With the cooperation of step 2, I think your problem will be solved.


Related articles: