Winforms 如何以编程方式设置datagrid行的背景色

Winforms 如何以编程方式设置datagrid行的背景色,winforms,c#-3.0,Winforms,C# 3.0,我有一个datagrid,而不是windows窗体中的gridview或datagridview。它是在Microsoft Visual Studio 2003中创建的。我已改为2008年。我应该根据条件更改datagrid的datarow 我在谷歌上搜索了一些例子,比如 void myDataGrid_加载行对象发送方,DataGridRowEventArgs e 但我没有任何DataGridRowEventArgs参数 我还发现了一个 http://www.syncfusion.com/fa

我有一个datagrid,而不是windows窗体中的gridview或datagridview。它是在Microsoft Visual Studio 2003中创建的。我已改为2008年。我应该根据条件更改datagrid的datarow

我在谷歌上搜索了一些例子,比如

void myDataGrid_加载行对象发送方,DataGridRowEventArgs e

但我没有任何DataGridRowEventArgs参数

我还发现了一个

http://www.syncfusion.com/faq/windowsforms/faq_c44c.aspx,它们会改变一个特定单元格的颜色

但是如何根据某些条件在Windows窗体中更改Datagrid中整行的颜色呢

提前谢谢

问候

skr

将此作为提示:

    private void dataGridView1_CellFormatting(object sender,         DataGridViewCellFormattingEventArgs e)
{
    foreach (DataGridViewRow Myrow in dataGridView1.Rows) 
    {            //Here 2 cell is target value and 1 cell is Volume
        if (Convert.ToInt32(Myrow .Cells[2].Value)<Convert.ToInt32(Myrow .Cells[1].Value))// Or your condition 
        {
            Myrow .DefaultCellStyle.BackColor = Color.Red; 
        }
        else
        {
            Myrow .DefaultCellStyle.BackColor = Color.Green; 
        }
    }