[英]Change color of specific part of DataGridView or entire column in C#
[英]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.