This code
CurrentSelectedRow = Me.dgvPreviouslyCut.CurrentRow.Index
stores the current selected row that has been clicked by the user in a data grid view control .
After refreshing the datasource for the data grid view, this code
Me.dgvPreviouslyCut.Rows(CurrentSelectedRow).Selected = True
programmatically re-selects the same row.
Immediately afterwards though
Me.dgvPreviouslyCut.CurrentRow.Index
is always set to zero, NOT the variable CurrentSelectedRow as you would expect.
Why does programmatically setting the select row index not cause the property CurrentRow.Index to be set to the same?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…