Select manually a row of dataGridView.

M

Mr. X.

Hello.
How can I manually select a row of a dataGridView.
The dataGridView is connected to a bindingSource,
and the row is added by :
Dim dr As DataRow
dr = MyDataTable.NewRow()
Rows(Rows.Count - 1).Selected = True ' is that correct ?

I mean that the new row, should be the current row.
How can I do that?

Thanks :)
 
A

Appr3nt1c3

Hello.
How can I manually select a row of a dataGridView.
The dataGridView is connected to a bindingSource,
and the row is added by :
        Dim dr As DataRow
        dr = MyDataTable.NewRow()
        Rows(Rows.Count - 1).Selected = True ' is that correct ?

I mean that the new row, should be the current row.
How can I do that?

Thanks :)

bindingcontext(dgv.datasource).position = dgv.rows.count - 1 ' for
datatable
bindingcontext(dgv.datasource,"datatablename").position =
dgv.rows.count - 1 ' for dataset
 
M

Mr. X.

That's doesn't work.
What I did instead is : setting the current cell to the current row :
dim dc as DataGridViewCell
dc = Rows(Rows.Count - 1).Cells(0)
CurrentCell = dc
CurrentRow.Selected = True
.... That's works.

Update the field works, but inserting doesn't !
I think this because the beginEdit method (or something else) should be
called.

Thanks :)
 

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