c# - Datagridview not selecting last row -


i selecting records datagridview... have got 5 rows in datgridview , trying select each , of them click of buton(nextrecordbutton). working running problem 4 rows selected , last row isn't selected. there doing wrong in code below:

private void btnnext_click(object sender, eventargs e) {    if (empcounter < dataset.tables[0].rows.count - 1)    {       txtdisplay.text = dataset.tables[0].rows[empcounter]["emp_name"].tostring();    } } 

this working running problem 4 rows selected , last row isn't selected.

because check checking till second last row

empcounter < dataset.tables[0].rows.count - 1 

it should be:

empcounter < dataset.tables[0].rows.count 

so code should be:

private void btnnext_click(object sender, eventargs e) {     if (empcounter < dataset.tables[0].rows.count)     {         txtdisplay.text = dataset.tables[0].rows[empcounter]["emp_name"].tostring();     } } 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -