初学者!C#能不能单独设置GridView某一个单元格里的字体和颜色
菜鸟求助!C#能不能单独设置GridView某一个单元格里的字体和颜色
单位做一个软件需要用GridView展示数据,表是做出来了,但是需求部门要求标题列项目字体不同,实在是不会,请教各位高手,有没有单独设置Gridview某一个单元格字体的办法?
------解决思路----------------------
------解决思路----------------------
手写的...就是这个意思了..
------解决思路----------------------
or
------解决思路----------------------
gv.rows[4].cells[3].Style.Font=new Font("宋体",12);
gv.rows[4].cells[3].Style.ForeColor=Color.Red;
单位做一个软件需要用GridView展示数据,表是做出来了,但是需求部门要求标题列项目字体不同,实在是不会,请教各位高手,有没有单独设置Gridview某一个单元格字体的办法?
------解决思路----------------------
DataGridViewCellStyle style = new DataGridViewCellStyle();
Font f = new Font("宋体",15,FontStyle.Bold) ;
style.Font = f;
style.ForeColor = Color.Red;
column.DefaultCellStyle = style; //column是你的datagrid 列 比如:DataGridViewTextBoxColumn
------解决思路----------------------
gv.rows[4].cells[3].backcolor=sys.drawing.color.red;
手写的...就是这个意思了..
------解决思路----------------------
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].Style.Font=new Font("宋体",12);
gv.rows[4].cells[3].Style.ForeColor=Color.Red;