Home All Groups Group Topic Archive Search About

Select manually a row of dataGridView.

Author
1 May 2010 9:51 AM
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 :)

Author
1 May 2010 11:56 AM
Appr3nt1c3
On 1 Mayo, 17:51, "Mr. X." <nospam@nospam_please.com> wrote:
> 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
Author
1 May 2010 4:38 PM
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 :)

Show quoteHide quote
"Appr3nt1c3" <guerrero.***@hotmail.com> wrote in message
news:cb93b2b9-d7db-4a20-94c3-edd6bdabd040@t14g2000prm.googlegroups.com...
> On 1 Mayo, 17:51, "Mr. X." <nospam@nospam_please.com> wrote:
>> 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
Author
1 May 2010 9:36 PM
Mr. X.
Problem solved.
Was a mistake of mine on code ...

Thank, anyway :)