Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to Select Row on a Datagrid (vb.net)

330 views
Skip to first unread message

savv...@nodalsoft.com.cy

unread,
Jan 18, 2008, 9:14:45 AM1/18/08
to
Hello,

I have a datagrid and i want programmaticly to change the value of the
CurrentRow

If I say

MyDG.Rows(i).selected=True

then The row backcolor gets blue but the Row is not selected
(you can stil see the small black arrow on the left pointing to the
previus Row)

How can I make this arrow point to the row i want to select ?

Thanks

Savvas Christodoulou
savv...@nodalsoft.com.cy

RobinS

unread,
Jan 20, 2008, 1:38:00 PM1/20/08
to
Just checking; is it a DataGrid or a DataGridView? .Net 1.1, 2.0, or 3.0?

RobinS.
----------------
<savv...@nodalsoft.com.cy> wrote in message
news:4fd82f6d-938f-4e0a...@i7g2000prf.googlegroups.com...

savv...@nodalsoft.com.cy

unread,
Jan 21, 2008, 3:22:03 AM1/21/08
to
On Jan 20, 8:38 pm, "RobinS" <rob...@imnottelling.com> wrote:
> Just checking; is it a DataGrid or a DataGridView? .Net 1.1, 2.0, or 3.0?
>
> RobinS.
> ----------------<savvas...@nodalsoft.com.cy> wrote in message

>
> news:4fd82f6d-938f-4e0a...@i7g2000prf.googlegroups.com...
>
>
>
> > Hello,
>
> > I have a datagrid and i want programmaticly to change the value of the
> > CurrentRow
>
> > If I say
>
> > MyDG.Rows(i).selected=True
>
> > then The row backcolor gets blue but the Row is not selected
> > (you can stil see the small black arrow on the left pointing to the
> > previus Row)
>
> > How can I make this arrow point to the row i want to select ?
>
> > Thanks
>
> > Savvas Christodoulou
> > savvas...@nodalsoft.com.cy- Hide quoted text -
>
> - Show quoted text -

Yes , sorry about that ... its a DataGridView,

RobinS

unread,
Jan 21, 2008, 3:34:00 AM1/21/08
to

Is your DataGridView bound to a data source? If so, try using a
BindingSource. Then you can set the selected row programmatically.

Dim myBindingSource as New BindingSource()
myBindingSource.DataSource = myDataSet
myDataGridView.DataSource = myBindingSource

myBindingSource.Position = 24

The BindingSource also has MoveNext, MovePrevious, MoveFirst, and MoveNext
methods that you can use to change the current position.

Does that help at all?

RobinS.
-----------------------------
<savv...@nodalsoft.com.cy> wrote in message
news:04434e03-2873-4dc5...@l32g2000hse.googlegroups.com...

savv...@nodalsoft.com.cy

unread,
Jan 22, 2008, 8:24:35 AM1/22/08
to
Yes thank u very mutch

+ I found another way to do it

DataGridView1.CurrentCell = DataGridView1.Rows(i).Cells(4)
I= the row u want to select
4 = a visible cell on ur datagridview

Thank You

0 new messages