如果单击复选框,如何为数据网格中的行着色?

时间:2012-06-05 07:21:14

标签: windows visual-c++ c++-cli

我有一个datagridview,我这样填写:

DataGridViewRow^ row = gcnew DataGridViewRow;

        DataGridViewCheckBoxCell^ CBox = gcnew DataGridViewCheckBox;//DataGridViewCheckBoxCell();
        row->Cells->Add( CBox );
        CBox->Value = false;
        CBox->ReadOnly = false;

        DataGridViewTextBoxCell^ PName = gcnew DataGridViewTextBoxCell();
        row->Cells->Add( PName );
        PName->Value = strPackageName;
        PName->ReadOnly = true;

        DataGridViewTextBoxCell^ AppV = gcnew DataGridViewTextBoxCell();
        row->Cells->Add( AppV );
        AppV->Value = strAppVendor;
        AppV->ReadOnly = true;

        DataGridViewTextBoxCell^ AppN = gcnew DataGridViewTextBoxCell();
        row->Cells->Add( AppN );
        AppN->Value = strAppName;
        AppN->ReadOnly = true;

dataGridView1->Rows->Add( row );

我想做以下事情。如果我单击复选框,我想更改行颜色。不幸的是我没有找到datagrid的相应事件,因为每个事件都有一些问题。 有些人可以告诉我应该使用哪个事件,或者我应该怎么做?

谢谢!

1 个答案:

答案 0 :(得分:0)

我希望它能奏效。

  if (CBox->Checked)
  {
      PName->BackColor = Color::Red;
      AppV->BackColor = Color::Red;
      AppN->BackColor = Color::Red;

  }
相关问题