DataGridView再確認後、元の行に戻る
2729 ワード
<pre name="code" class="html">//
int _currentRow = 0;
//int _currentColumn = 0;
switch (modMark)
{
case 1:
if (dgvHis.CurrentCell != null)
{
_currentRow = this.dgvHis.CurrentCell.RowIndex;
//_currentColumn = this.dgvHis.CurrentCell.ColumnIndex ;
}
break;
case 2:
if (dgvBank.CurrentCell != null)
{
_currentRow = this.dgvBank.CurrentCell.RowIndex;
//_currentColumn = this.dgvBank.CurrentCell.ColumnIndex;
}
break;
}
//
switch (modMark)
{
case 1:
if (dgvHis.Rows.Count > 0)
{
if (dgvHis.Rows.Count >= _currentRow)
{
dgvHis.Rows[_currentRow].Selected = true;
dgvHis.FirstDisplayedScrollingRowIndex = _currentRow;
}
else
{
dgvHis.Rows[dgvHis.Rows.Count - 1].Selected = true;
dgvHis.FirstDisplayedScrollingRowIndex = dgvHis.Rows.Count - 1;
}
}
// if (dgvHis.Columns.Count > _currentColumn)
// {
// dgvHis.Columns[_currentColumn].Selected = true;
// }
// else
// {
// dgvHis.Columns[dgvHis.Columns.Count - 1].Selected = true;
// }
break;
case 2:
if (dgvBank.Rows.Count > 0)
{
if (dgvBank.Rows.Count >= _currentRow)
{
dgvBank.Rows[_currentRow].Selected = true;
dgvBank.FirstDisplayedScrollingRowIndex = _currentRow;
}
else
{
dgvBank.Rows[dgvBank.Rows.Count - 1].Selected = true;
dgvBank.FirstDisplayedScrollingRowIndex = dgvBank.Rows.Count - 1;
}
}
// if (dgvBank.Columns.Count > _currentColumn)
// {
// dgvBank.Columns[_currentColumn].Selected = true;
// }
// else
// {
// dgvBank.Columns[dgvBank.Columns.Count - 1].Selected = true;
// }
break;
}