gpt4 book ai didi

datagridview - 如何在 c#.net 的 datagridview 中设置整个列的背景颜色(Readonly 列的指示)

转载 作者:行者123 更新时间:2023-12-02 05:20:34 28 4
gpt4 key购买 nike

我有一个数据 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com