I have a DataGridView where I am scanning in checks from a keyboard emulated device.
While keypreview is on and I’m waiting for input, the user cannot type anything in otherwise it grabbed by my method to read the input by the check reader. All this is working fine.
After the scan, I am adding to the datagridview a row, which is being put at the end.
How do I make the datagridview scroll to the bottom after each add? I wind up with a few hundred checks and it’s at the top. So, every time they scan, they have no idea what was scanned in.
This is my method that creates the row:
private void Timer1Tick(object sender, EventArgs e)
{
_secondswaited += 1;
if (_secondswaited == SecondsToWait)
{
timer1.Enabled = false;
var psc = new ParseScannedCheckNumbers();
if (psc.ParseCheck(_checkData))
{
label_Status.Text = @"Scan Next Check";
var ct = checkTrans.IndividualCheck.NewIndividualCheckRow();
ct.Date = DateTime.Now.ToShortDateString();
ct.AccountNumber = GetAccountNumber(psc.BankAccountNumber);
ct.Name = GetAccountName(ct.AccountNumber);
ct.AccountBalance = GetAccountBalance(ct.AccountNumber);
//ct.CheckAmount = 0;
ct.BankRoutingNumber = psc.BankRoutingNumber;
ct.BankAccountNumber = psc.BankAccountNumber;
ct.CheckNumber = psc.CheckNumber;
ct.Status = "Entered";
checkTrans.IndividualCheck.Rows.Add(ct);
var dgvcount = dgv_Checks.Rows.Count;
**dgv_Checks.Rows[dgvcount - 1].Selected = true;**
}
else
{
label_Status.Text = @"Scan failed. Rescan check.";
}
_checkData = string.Empty;
_secondswaited = 0;
var rs = new Registry.RegistrySettings();
if (!rs.ScanChecksContinuous)
{
StopScanning();
label_Status.Text = @"Success!";
EditLastRowEntered();
}
label_ChecksScanned.Text = (dgv_Checks.RowCount - 1).ToString();
}
}
The part that is bold is where I attempted to move to the last row, without success.
Thanks!
I’d use the DataGridView.CurrentCell property. Try this in place of the line you’re having problems with: