300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > DataGridView中在新增行时怎样设置每个Cell单元格的字体样式

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

时间:2018-11-05 03:58:43

相关推荐

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

场景

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

/BADAO_LIUMANG_QIZHI/article/details/102814145

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

注:

博客主页:

/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);//添加的行作为最后一行

效果

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。