所有行:
dataGridView1.RowsDefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Strikeout);
dataGridView1.RowsDefaultCellStyle.ForeColor = Color.Blue;
dataGridView1.RowsDefaultCellStyle.BackColor = Color.Red;
选中行
dataGridView1.SelectedRows[0].DefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Strikeout);
dataGridView1.SelectedRows[0].DefaultCellStyle.ForeColor = Color.Blue;
dataGridView1.SelectedRows[0].DefaultCellStyle.BackColor = Color.Red;
属性里找啊
dgvStatusCodes.Columns[0].DefaultCellStyle.BackColor = Color.Red;
多行的话:
datagridview.Rows[i].Cells[0].BackColor=Color.Blue;
选中多行:
datagridview.SelectedRows[i].Cells[0].BackColor=Color.Blue;
当行:
datagridview.Rows[0].Cells[0].BackColor=Color.Blue;
选中单行:
datagridview.SelectedRows[0].Cells[0].BackColor=Color.Blue;
方法1:
//列Header的背景色为黄色
DataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Yellow;
方法2:
DataGridView1.EnableHeadersVisualStyles = false;
DataGridView1.Columns[0].HeaderCell.Style.BackColor = Color.Blue;
//DataGridView1.Columns[i] i写想要的列号就可以了。
以上就是土嘎嘎小编大虾米为大家整理的设置datagridview某一行的颜色_datagridview绑定数据源相关主题介绍,如果您觉得小编更新的文章对您有所帮助,不要忘记讲本站分享给您身边的朋友哦!!