i have a dataGridView with 2 columns of checkbox i want if the first checkbox value changed to be false i want to disable the next cell in the same row i write the following code but it done after another click
this->dataGridView1->CellValidated += gcnew
System::Windows::Forms::DataGridViewCellEventHandler(this,
&categoryOptionDialog::dataGridView1_CellValidated );
and function is
private: System::Void dataGridView1_CellValidated(System::Object^ sender,
System::Windows::Forms::DataGridViewCellEventArgs^ e)
{
try{
int j = dataGridView1->CurrentCell->RowIndex;
if (dataGridView1->Rows[j]->Cells[1]->Value->ToString() !=
"True")
{
DataGridViewCell^ cell = dataGridView1->Rows[j]->Cells[2];
DataGridViewCheckBoxCell^ chkCell =
(DataGridViewCheckBoxCell^)cell;
chkCell->Value = false;
chkCell->FlatStyle = FlatStyle::Flat;
chkCell->Style->ForeColor = System::Drawing::Color::DarkGray;
cell->ReadOnly = true;
}
else
{
DataGridViewCell^ cell = dataGridView1->Rows[j]->Cells[2];
DataGridViewCheckBoxCell^ chkCell =
(DataGridViewCheckBoxCell^)cell;
chkCell->FlatStyle = FlatStyle::Standard;
chkCell->Style->ForeColor = System::Drawing::Color::White;
cell->ReadOnly = false;
}
dataGridView1->Update();
}
catch (...){}
}
Aucun commentaire:
Enregistrer un commentaire