"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 shoul开发者_C百科d reset all cells below from his position
Is it possible! Or any suggestion
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);
}
it will reset their initial position
精彩评论