繁体   English   中英

更改帐户列中单元格的文本颜色(C# datagridview)

[英]Change text color of cells in Account column (C# datagridview)

我试图在程序加载时更改 Account 列中所有行的字体颜色,但收效甚微。 我在这里做错了什么吗?

到目前为止,这是我的代码:

private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
    if (this.dataGridView1.Columns[e.ColumnIndex].Name == "Account")
    {
        e.CellStyle.ForeColor = Color.Blue;
    }
}

这个这个(它将用蓝色为这一行文本着色):

this.dataGridView1.Columns["Account"].DefaultCellStyle.ForeColor = Color.Blue;

只需添加以下行:

this.previousRentDataGridViewTextBoxColumn.ItemStyle-ForeColor = <color>;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM