0
点赞
收藏
分享

微信扫一扫

DataGridView中在新增行时怎样设置每个Cell单元格的字体样式


场景

DataGridView怎样实现添加、删除、上移、下移一行:

在上面中应用到了新增一行时如果对某个单元格中的字体大小、是否加粗、字体居中显示等有要求,要怎样设置。

注:

实现

DataGridViewRow dr = new DataGridViewRow();
dr.CreateCells(this.dataGridView_Task_ViewEdit);
//第一个单元格不赋值
//dr.Cells[0].Value = "1111";

dr.Cells[1].Value = "步_" + (this.dataGridView_Task_ViewEdit.Rows.Count + 1).ToString();

Font font = new Font("宋体",14,FontStyle.Bold);
dr.Cells[2].Style.Font = font;
dr.Cells[2].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[2].Value = "搁置";

dr.Cells[3].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[3].Value = "步时间>0.000秒 下一步";

dr.Cells[4].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[4].Value = "时间>1.000秒";

dr.Cells[5].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[5].Value = "低";

dr.Cells[6].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[6].Value = "0";

this.dataGridView_Task_ViewEdit.Rows.Add(dr);//添加的行作为最后一行

效果

 

DataGridView中在新增行时怎样设置每个Cell单元格的字体样式_DataGridView

举报

相关推荐

0 条评论