简体   繁体   中英

.net 2.0 datagrid view combobox windows application

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#

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(....);
    }
  }
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(....); 
     } 
 } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM