Select manually a row of dataGridView.

  • Thread starter Thread starter Mr. X.
  • Start date Start date
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 :)
 
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
 
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 :)
 
Back
Top