DataGridView中在新增行时怎样设置每个Cell单元格的字体样式
<h1>场景</h1><p>DataGridView怎样实现添加、删除、上移、下移一行:</p>
<p><a href="https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/102814145">https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/102814145</a></p>
<p>在上面中应用到了新增一行时如果对某个单元格中的字体巨细、是否加粗、字体居中表现等有要求,要怎样设置。</p>
<p>注:</p>
<p>博客主页: <br /><a href="https://blog.csdn.net/badao_liumang_qizhi">https://blog.csdn.net/badao_liumang_qizhi</a>
<br />关注公众号 <br />霸道的步伐猿 <br />获取编程相干电子书、教程推送与免费下载。 </p>
<h1>实现</h1>
<p> </p>
DataGridViewRow dr = new DataGridViewRow();
dr.CreateCells(this.dataGridView_Task_ViewEdit);
//第一个单元格不赋值
//dr.Cells.Value = "1111";
dr.Cells.Value = "步_" + (this.dataGridView_Task_ViewEdit.Rows.Count + 1).ToString();
Font font = new Font("宋体",14,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 = "0";
this.dataGridView_Task_ViewEdit.Rows.Add(dr);//添加的行作为末了一行
<p> </p>
<h2>效果</h2>
<p></p>
<p> </p>
<p> </p>
<p><img/></p>
页:
[1]