110,533
社区成员
发帖
与我相关
我的任务
分享
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int j = 0; j < e.Row.Cells.Count; j++)
{
e.Row.Cells[j].Style.Add("BORDER-BOTTOM", "#aaccee 1px solid");
e.Row.Cells[j].Style.Add("BORDER-RIGHT", "#aaccee 1px solid");
e.Row.Cells[j].Style.Add("padding-left", "5px");
}
}
or
protected void Grid_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int number;
var highestCells = e.Row.Cells.Cast<TableCell>()
.Where(tc => int.TryParse(tc.Text, out number))
.OrderByDescending(c => int.Parse(c.Text));
foreach(var cell in highestCells)
cell.Font.Bold = true;
}
}
gv.rows[4].cells[3].backcolor=sys.drawing.color.red;
手写的...就是这个意思了..
DataGridViewCellStyle style = new DataGridViewCellStyle();
Font f = new Font("宋体",15,FontStyle.Bold) ;
style.Font = f;
style.ForeColor = Color.Red;
column.DefaultCellStyle = style; //column是你的datagrid 列 比如:DataGridViewTextBoxColumn