vb.net 在 ASP.NET 中强制 Gridview Header 字体粗体为 false
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29508915/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Forcing Gridview Header font bold to false in ASP.NET
提问by lulutanseco
I am having a problem in forcing gridview header to "unbold". I tried using the Gridview parameter for header font style but it doesn't really work. Unfortunately, all other methods I tried did not work.
我在强制 gridview 标题“取消粗体”时遇到问题。我尝试将 Gridview 参数用于标题字体样式,但它并没有真正起作用。不幸的是,我尝试过的所有其他方法都不起作用。
- Using CSS Class
- 使用 CSS 类
.headercell
{
font-weight: normal;
font-size: 12px;
font-family: "Franklin Gothic Book"
}
Programmatically using Row Data Bound
If e.Row.RowType = DataControlRowType.Header Then For i = 0 To GridView1.Columns.Count - 1 GridView1.Columns(i).HeaderStyle.Font.Bold = False Next End If
以编程方式使用行数据绑定
If e.Row.RowType = DataControlRowType.Header Then For i = 0 To GridView1.Columns.Count - 1 GridView1.Columns(i).HeaderStyle.Font.Bold = False Next End If
What would be the most efficient way to set the gridview header to unbold?
将 gridview 标题设置为取消粗体的最有效方法是什么?
UPDATE (ASPX CODE):
更新(ASPX 代码):
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor="#333333" BorderStyle="Solid" BorderWidth="2px"
CellPadding="3" Font-Bold="false" Font-Overline="False"
Font-Size="Small" Font-Underline="False" HtmlEncode="false">
<RowStyle ForeColor="#000066" Height="23px" HorizontalAlign="Center"
VerticalAlign="Middle" />
<FooterStyle BackColor="White" ForeColor="#000066" />
<PagerStyle BackColor="White" ForeColor="#000066"
HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#002851" Font-Bold="False"
CssClass="headercell" ForeColor="White" HorizontalAlign="Left"
VerticalAlign="Middle" />
<Columns>
<asp:TemplateField HeaderText="STATUS" ShowHeader="False"
Visible="True">
<ItemTemplate>
<asp:Button ID="Btn1" runat="server" CommandArgument='<%#
DataBinder.Eval(Container, "RowIndex") %>'
CommandName="Btn1_cmd">
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
采纳答案by Shyju
Add a CssClass namely "gvstyling" to your gridview
添加一个 CssClass 即“gvstyling”到你的 gridview
Write a css just like this...
像这样写一个css...
.gvstyling th
{
font-size: 12px;
font-weight: normal;
}
回答by Izzy
You can use HeaderStyle-Font-Boldon your <asp:BoundField />So just set it to false as following
您可以HeaderStyle-Font-Bold在您的<asp:BoundField />So上使用,只需将其设置为 false 如下
HeaderStyle-Font-Bold="false"
回答by lulutanseco
This is the cssclass I added to the Gridview:
这是我添加到 Gridview 的 cssclass:
.Grid, .Grid th, .Grid td
{
border-color: #CCCCCC;
font-family: Franklin Gothic Book;
font-size: 12px;
font-weight: normal;
}
In the source code, I just added CssClass="Grid" to the Gridview (not in header cssclass).
在源代码中,我只是将 CssClass="Grid" 添加到 Gridview(不在标题 cssclass 中)。
回答by Rahul Nikate
Try below :
试试下面:
th {
font-weight: normal;
}

