运算符> =不能应用于方法组和int类型的操作数

时间:2014-02-18 09:28:33

标签: if-statement for-loop datagridview

这样做的正确方法是什么

     private void grid1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
        for (int i = 0; i < grid1.Rows.Count; i++)
        {
            if (grid1.Rows[i].Cells[6].Value.Equals >= (740))
            {
                grid1.Rows[i].Cells[6].Style.BackColor = System.Drawing.Color.Red;
            }

1 个答案:

答案 0 :(得分:0)

您只需要查看Value即可。 Equals()是一种检查相等性的方法。

private void grid1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
    for (int i = 0; i < grid1.Rows.Count; i++)
    {
        if (grid1.Rows[i].Cells[6].Value >= 740)
        {
            grid1.Rows[i].Cells[6].Style.BackColor = System.Drawing.Color.Red;
        }