更改每三个单元格的datagrid单元格颜色 [英] Change datagrid cell color of every third cell
本文介绍了更改每三个单元格的datagrid单元格颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将每三个单元格颜色更改为红色,其4×4数据网格使我难以用作行和列索引?香港专业教育学院得到了什么
Hi i need to change every third cell color into red its a 4 by 4 datagrid i struggle with what to use as my row and column index? this is what ive got
private void btnred_Click(object sender, EventArgs e)
{
int teller;
for (teller = 1; teller <= 16; teller++)
{
DataGridViewCellStyle CellStyle = new DataGridViewCellStyle();
CellStyle.BackColor = Color.Red;
dgvArray.Rows[(this parts i dont know)].Cells[].Style = CellStyle;
teller += 1;
}
}
推荐答案
foreach (DataGridViewRow row in dgvArray.Rows)
{
DataGridViewCellStyle CellStyle = new DataGridViewCellStyle();
CellStyle.BackColor = Color.Red;
row.Cells["Third_Column_Name"].Style = CellStyle;
}
希望对您有所帮助.
Hope it helps.
这篇关于更改每三个单元格的datagrid单元格颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文