作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个数据 GridView ,我想在其中将两列的 readonly
设置为 true
。我想更改这些列的颜色。每当我离开单元格时,我只能让第一个单元格和当前单元格改变颜色。其余电池不工作。谁能帮我解决这个问题?
最佳答案
尝试
private void dataGridView2_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 0)
if (dataGridView2[e.ColumnIndex, e.RowIndex].ReadOnly)
e.CellStyle.BackColor = Color.Red;
if (e.ColumnIndex == 1)
if (dataGridView2[e.ColumnIndex, e.RowIndex].ReadOnly)
e.CellStyle.BackColor = Color.Black;
}
关于datagridview - 如何在 c#.net 的 datagridview 中设置整个列的背景颜色(Readonly 列的指示),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13908200/
我是一名优秀的程序员,十分优秀!