how to select the newly added row in datagridview

M

mike

I have a datagridview control and a button on the windows form. I am
adding a new row in button click event. When the number of rows grow,
the newly added row will not be
visible but a scroll bar will be shown.

I want the program to highlight the newly added row and make it visible

in the datagridview by scrolling to that position when a new row was
added by button click event. How can you do that? Thanks in advance.
 
V

vbnetdev

Me.DataGridView1.DataSource = dt
Me.DataGridView1.MultiSelect = False
Me.DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
Me.DataGridView1.CurrentCell = Me.DataGridView1.Item(0, 2)
(obviosuly find the cell of the newly added row by checking the row count
of your dataset or collection that is bound)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top