Login
网站首页 > 文章中心 > 其它

设置datagridview某一行的颜色_datagridview绑定数据源

作者:小编 更新时间:2023-07-27 15:38:37 浏览量:193人看过

所有行:

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绑定数据源相关主题介绍,如果您觉得小编更新的文章对您有所帮助,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章