您好,我想比較兩個單元格,它們都具有數字值。 如果Cell1大於cell2,則顏色單元爲綠色。如果DataGridView的單元格值大於另一個單元格
這裏是我的代碼:在單元格格式化中的datagridview
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
if (row.Cells[3].Value.ToString() > (row.Cells[4].Value.ToString()))
{
row.Cells[3].BackColor = Color.PaleGreen;
}
,但我得到了兩個錯誤:在第一線操作員「>」不能應用於類型「串」和「串」和操作數第二行System.Windows.Forms.DataGridViewCell'不包含'BackColor'的定義,並且沒有可接受類型'System.Windows.Forms.DataGridViewCell'的第一個參數的擴展方法'BackColor'
誤差只有轉讓,電話,遞增,遞減和新對象表達式可以用作聲明 – user6894907
對不起,該代碼固定小語法錯誤... – rmc00
我在這一行中得到這個錯誤:else(value1> value2); – user6894907