DataGridView
フォームとコントロールに基づくアプリケーションを作成しています。
私はデータベースから情報をバインドしています。今やろうとしているのは、値に応じて列プロパティのフォントスタイルと色を変更すること"Urgent","Haute","Normale"
です。
これが私が使用しているコードですが、機能しませんでした。誰かが以下のコードの何が問題になっているのか教えてもらえますか?
コード:
private void ColorizeCellsbyValue() {
DataGridViewCellStyle BoldRed = null;
BoldRed = new DataGridViewCellStyle();
BoldRed.Font = new Font("Tahoma", 9, FontStyle.Bold);
BoldRed.ForeColor = Color.Red;
DataGridViewCellStyle Red = null;
Red = new DataGridViewCellStyle();
Red.ForeColor = Color.Red;
DataGridViewCellStyle Black = null;
Black = new DataGridViewCellStyle();
Black.ForeColor = Color.Black;
string priority;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
priority = row.Cells[3].Value.ToString();
switch (priority)
{
//Change font
case "Urgent":
row.Cells[3].Style = BoldRed;
break;
case "Haute":
row.Cells[3].Style = Red;
break;
case "Normale":
row.Cells[3].Style = Black;
break;
default:
row.Cells[3].Style = Black;
break;
}
}
}