如何在网格视图中加粗前三行字体粗体? [英] How to bold top 3 rows font bold in grid view ?

查看:127
本文介绍了如何在网格视图中加粗前三行字体粗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi frnds 



在网格视图中如何加粗前3行字体..请帮助我,我试过这样的




In grid view how to bold top 3 rows font ..please help me i have tried like this

protected void grdOlymp_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[1].Font.Bold = true;
        }




if i tried like this the total 1st column getting bold ,but i need to bold top 3 rows  please give me some solution guys 

thank u

推荐答案

从jQuery检查less-then函数 [ ^ ]



CSS中还有伪选择器:





您可以在CSS文件中使用它(对于完整行选择):

Check less-then function from jQuery[^]

There is also pseudo-selector in CSS:


You would use it like this (for full row select) in your CSS file:
your-grid-selector tr:lt(3) { font-weight: bold; }





如果您只需要一列,则添加:nth-上面的选择器的子(列索引)。



if you need only one column then add :nth-child(column-index) to the selector above.

your-grid-selector tr:lt(3):nth-child(1){ font-weight: bold; }









如果你必须拥有服务器端(坏主意):

检查此事件 [ ^ ]





请注意,这只会改变第二列,因为整行必须删除行的一部分。





If you absolutely have to have it server side (bad idea):
Check this event[^]


Note that this will change only second column, for the whole row you have to remove Cells part of the line :)

protected void grdOlymp_DataBindingComplete (object sender, DataGridViewBindingCompleteEventArgse)
    {
        for (int i=0; i <= 2; i++)
            grdOlymp.Rows[i].Cells[1].Font.Bold = true;

        }







如果这有帮助,请花时间接受解决方案,以便其他人可以找到它。谢谢。




If this helps, please take time to accept the solution so that others may find it. Thank you.


使用以下代码进行前三行的条件格式化:

Use the following Code to make the conditional formatting of first three rows:
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {   
    for (int i=0;i<3;i++)
    {
        if(e.Row.RowType == DataControlRowType.DataRow)  
        {
                e.Row.ForeColor = System.Drawing.Color.Crimson;  
                e.Row.Font.Italic = true;  
                e.Row.BackColor = System.Drawing.Color.LightPink;  
              
        }  
    }
}  


这篇关于如何在网格视图中加粗前三行字体粗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆