场景

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

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/102814145

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

注:

博客主页:
https://blog.csdn.net/badao_liumang_qizhi

关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

           DataGridViewRow dr = new DataGridViewRow();
dr.CreateCells(this.dataGridView_Task_ViewEdit);
//第一个单元格不赋值
//dr.Cells[0].Value = "1111"; dr.Cells[].Value = "步_" + (this.dataGridView_Task_ViewEdit.Rows.Count + ).ToString(); Font font = new Font("宋体",,FontStyle.Bold);
dr.Cells[].Style.Font = font;
dr.Cells[].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[].Value = "搁置"; dr.Cells[].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[].Value = "步时间>0.000秒 下一步"; dr.Cells[].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[].Value = "时间>1.000秒"; dr.Cells[].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[].Value = "低"; dr.Cells[].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dr.Cells[].Value = ""; this.dataGridView_Task_ViewEdit.Rows.Add(dr);//添加的行作为最后一行

效果

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

04-19 16:57