如何将forecolor放在datagridview中所有行的最后一列 [英] how to put forecolor in last column of all the rows in datagridview

查看:80
本文介绍了如何将forecolor放在datagridview中所有行的最后一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,其中列是名称,类型,大小,日期。



数据显示在gridview中。



i希望日期列的所有行都变为红色。



如何在属性中更改



如果有人可以帮助我,将有义务。



提前感谢

解决方案

< blockquote>

  for  int  i =  0 ; i <  gridview1.Rows.Count; i ++)
{
gridview1.Rows [i]。单元格[gridview1.Columns.Count - 1 ]。BackColor = Color.Red;
}







如果有帮助,请接受回答并投票。


 gridcss  
{
background 红色;
color 白色;
}







 受保护  Sub  gvdata_RowDataBound(发件人作为 对象,e 作为 GridViewRowEventArgs)
如果 e.Row.RowType = DataControlRowType.DataRow 然后
e.Row.Cells( 3 )。CssClass = gridcss

结束 如果
结束 Sub


i have one form where columns are name,type,size,date.

the data displays in gridview.

i want all the rows of date column to get in red colour.

how to change that in properties

Will be obliged if anyone can help me.

thanks in advance

解决方案

for (int i = 0; i < gridview1.Rows.Count; i++)
            {
                gridview1.Rows[i].Cells[gridview1.Columns.Count - 1].BackColor = Color.Red;
            }




Accept as answer and vote if help.


.gridcss
{
background:Red;
color:White;
}




Protected Sub gvdata_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(3).CssClass = "gridcss"

End If
End Sub


这篇关于如何将forecolor放在datagridview中所有行的最后一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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