C# 如何在DatagridView组合框SelectedIndexChanged更改事件上重置DatagridView组合框单元格

C# 如何在DatagridView组合框SelectedIndexChanged更改事件上重置DatagridView组合框单元格,c#,datagridviewcomboboxcell,C#,Datagridviewcomboboxcell,“这是关于在更改另一个数据网格组合框单元格时重置数据网格视图组合框单元格的所有内容” 例如: 如果我在DataGridView中有四行,它们都包括组合框 如果我在所有选项中都选择“值” 然后,我只需更改任何组合框单元格的第一行中的值,这样相应的事件就会从其位置重置下面的所有单元格 有可能吗!或者任何建议 private void Grid_ComboBox_SelectedIndexChanged(object sender, EventArgs e) { int X_access =

“这是关于在更改另一个数据网格组合框单元格时重置数据网格视图组合框单元格的所有内容”

例如: 如果我在DataGridView中有四行,它们都包括组合框 如果我在所有选项中都选择“值” 然后,我只需更改任何组合框单元格的第一行中的值,这样相应的事件就会从其位置重置下面的所有单元格

有可能吗!或者任何建议

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)
    {
    }
}
它将重置它们的初始位置


如果它是第二行,那么第一行应该重置怎么办?这是否意味着只有一行选择了所有组合框?在这种情况下,第三行和第四行单元格将被重置,我的意思是重置的流程是从上到下我希望这会对您有所帮助我也尝试了这一行
foreach (Control field in container.Controls)
{
    if (field is ComboBox)
        ((ComboBox)field).SelectedIndex = 0;
    else
        dgView.DataSource = null;
        ClearAllText(field);
}