2012-06-05 44 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