datagridviewselectedindexchangeddatagridviewcombobox

How to change the value of specific column in DataGridView based on selected index changed of DataGridViewComboxColum?


I have a DataGridViewComboxColum named “cbxActionType” on my windows form application which have the following values in its item collection. • For Information • For Comment • For Review … etc. DataGridView1 has a column named “NDays” which stores numbers of days. How do I set the NDays column value to 0 (zero days) if the “cbxActionType” selected value is changed to “For Information”?

DataGridview Combobox Column


Solution


private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
    if (dataGridView1.CurrentRow.Cells["cbxActionType"].Value == "For Information")
    {
        dataGridView1.CurrentRow.Cells["NDays"].Value = 0;               
    }
}