S
sklett
I have a 2 column DGV. When a user enters a value in cell 0,0 I want to set
cell 0,1 as current, when they enter a value in cell 0,1 I want to set cell
1,0 current, etc, etc
basically zig-zagging down the rows from left to right.
I'm calling this method below in my CellEndEdit event:
private void AdvanceCellFocus(DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
dataGridView_SerialNumberLinks.CurrentCell =
dataGridView_SerialNumberLinks[e.ColumnIndex + 1, e.RowIndex];
}
else
{
if (e.RowIndex < dataGridView_SerialNumberLinks.Rows.Count)
{
dataGridView_SerialNumberLinks.CurrentCell =
dataGridView_SerialNumberLinks[e.ColumnIndex - 1, e.RowIndex
+ 1];
}
}
}
The result is this:
- Data entered into cell 0,0
- AdvanceCellFocus() called and sets cell 0,1 as current
- when control returns to the UI, cell 1,1 is current.
So the problem appears to be that the default behavior of advancing a row
upon completing an edit operation is still happening. I'm not finding a way
to deal with it.
Anyone have any ideas? Suggestions?
Thanks for reading,
Steve
cell 0,1 as current, when they enter a value in cell 0,1 I want to set cell
1,0 current, etc, etc
basically zig-zagging down the rows from left to right.
I'm calling this method below in my CellEndEdit event:
private void AdvanceCellFocus(DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
dataGridView_SerialNumberLinks.CurrentCell =
dataGridView_SerialNumberLinks[e.ColumnIndex + 1, e.RowIndex];
}
else
{
if (e.RowIndex < dataGridView_SerialNumberLinks.Rows.Count)
{
dataGridView_SerialNumberLinks.CurrentCell =
dataGridView_SerialNumberLinks[e.ColumnIndex - 1, e.RowIndex
+ 1];
}
}
}
The result is this:
- Data entered into cell 0,0
- AdvanceCellFocus() called and sets cell 0,1 as current
- when control returns to the UI, cell 1,1 is current.
So the problem appears to be that the default behavior of advancing a row
upon completing an edit operation is still happening. I'm not finding a way
to deal with it.
Anyone have any ideas? Suggestions?
Thanks for reading,
Steve