0

"This is all about reset Data Grid View combo box cell when i change the Another data grid combo box Cell"

Example :: If i have four rows in DataGridView they all including combo box If i select value in all of them Than i just change the value in first rows any combo box cell so respective event should reset all cells below from his position

Is it possible! Or any suggestion

bliss
  • 330
  • 3
  • 14
ertjain
  • 1
  • 1
  • 1
  • What if its the second row, so first row should be reset ? Does it imply than only one row with all ComboBox selected should occur ? – V4Vendetta Jul 22 '11 at 09:04
  • IN this case Third and fourth rows cell will be reset i mean flows of reset is from up to down – ertjain Jul 22 '11 at 09:27

2 Answers2

0
foreach (Control field in container.Controls)
{
    if (field is ComboBox)
        ((ComboBox)field).SelectedIndex = 0;
    else
        dgView.DataSource = null;
        ClearAllText(field);
}

it will reset their initial position

Delphy
  • 1
0
private void Grid_ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
    int X_access = -1;
    int Y_access = -1; 

    // Reset DatagridView ComboBox cell On the DatagridView ComboBox
    if (dataGridView_preView.CurrentCell.RowIndex == 0)
    {
        X_access = dataGridView_preView.CurrentCellAddress.Y; // find Cell position 
        Y_access = dataGridView_preView.CurrentCellAddress.X;
        dataGridView_preView.Rows[X_access + 1].Cells[Y_access].Value = ""; // reset
        dataGridView_preView.Rows[X_access + 2].Cells[Y_access].Value = "";
        dataGridView_preView.Rows[X_access + 3].Cells[Y_access].Value = "";
    }

    else if (dataGridView_preView.CurrentCell.RowIndex == 1)
    {
        dataGridView_preView.Rows[X_access + 1].Cells[Y_access].Value = "";                  
        dataGridView_preView.Rows[X_access + 2].Cells[Y_access].Value = "";
    }
    else if (dataGridView_preView.CurrentCell.RowIndex == 2)
    {
    }
    else if (dataGridView_preView.CurrentCell.RowIndex == 3)
    {
    }
}
Anton Moiseev
  • 2,834
  • 4
  • 24
  • 30