0

“这都是关于当我更改另一个数据网格组合框单元格时重置数据网格视图组合框单元格”

示例 :: 如果我在 DataGridView 中有四行,它们都包括组合框

可能吗!或任何建议

4

2 回答 2

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)
    {
    }
}
于 2011-07-22T11:38:06.957 回答
0
foreach (Control field in container.Controls)
{
    if (field is ComboBox)
        ((ComboBox)field).SelectedIndex = 0;
    else
        dgView.DataSource = null;
        ClearAllText(field);
}

它将重置它们的初始位置

于 2015-07-15T13:10:25.967 回答