Point datagridview row while it is added.

Hi All,

I add data to datagridview via datatable as datasource.

I want to show to user its progress while added to it.

Please see below code, the purpose is work, but always left behind one row.
I mean while pointer point to row one, the second row data is already added.

How could I do it?

Thank you.
Dim row As DataRow = dtResult.NewRow()

        Me.dgvHasilProses.Refresh()

        ERV_Global.Locate_DataGridView_Row(dgvHasilProses, dtResult.Rows.Count - 1)

        row("Id") = strEmpCode
        row("DateLog") = dteDateLog.ToString("dd MMM yyyy")
       
        dtResult.Rows.Add(row)

Open in new window

LVL 1
emi_sastraAsked:
Who is Participating?
 
ZhaolaiConnect With a Mentor Commented:
Try switching two of the lines and adding DoEvents:


Dim row As DataRow = dtResult.NewRow()

ERV_Global.Locate_DataGridView_Row(dgvHasilProses, dtResult.Rows.Count - 1)
Me.dgvHasilProses.Refresh()
Application.DoEvents()
row("Id") = strEmpCode
row("DateLog") = dteDateLog.ToString("dd MMM yyyy")

dtResult.Rows.Add(row)

Open in new window

0
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
Hi emi...
you mean that always there is a new row (empty) after you add yours?
0
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
after you add the new row ...set Me.datagridview.CancelEdit
0
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
use :
 Me.MyDataGridView.Rows(Me.MyDataGridView.Rows.Count - 1).Selected = True
0
 
emi_sastraAuthor Commented:
Hi Zhaolai,

It works.

Thank you very much for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.