views:

340

answers:

2

I have a data grid, a new row is added when i click on button. the new row consists of dropdowns in each cell. the value of the next cell dropdown must be based on the first cell drop down and so on for the third cell. I am using a .net 2.0 windows application in c#

+1  A: 

Use the CellEndEdit event and check what is selected when the first drop down is edited, then you can manipulate the others.

private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
  {
  if (e.ColumnIndex == dataGridViewFirstDropColumn.Index) //or your first column name.Index
    {
    //Maniputlate other drop down options (e.g. dataGridView[SecondColumnIndex, e.RowIndex].Items.Add(....);
    }
  }
ThePower
A: 
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) 
{ 
     if (e.ColumnIndex == dataGridViewFirstDropColumn.Index) 
     //or your first column name.Index 
     { 
          //Maniputlate other drop down options (e.g. dataGridView[SecondColumnIndex, 
            e.RowIndex].Items.Add(....); 
     } 
 }
ss