场景
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[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);//添加的行作为末了一行
复制代码
效果
|