2012-06-05 25 views
0

我有一个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的相应事件,因为每个事件都有一些问题。 有人可以告诉我应该使用哪个事件,或者我该怎么做?

谢谢!

回答

0

我希望它能起作用。

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

    } 
+0

我知道如何设置颜色,我只是不知道要使用哪个事件。我的问题是,如果我点击一个复选框,然后值改变,但单元格进入编辑模式,如果我再次更改该值而不更改单元格选择,它将不再工作,单元格我更改单元格选择 – kampi