By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

Show dynamically selected row in datagridview

P: n/a
I have a datagridview which is populated via a datatable.

What I would like to dynamically set a selected row and have that row
show up in the datagridview and not have to manually scroll to find the
selected row.

I had a look for all kind of "datagridview1.rows(i).focus" but there
doesnt seem to be anything. Can anyone help? I know this must be quite
simple to do but cant find it.

May 31 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
try:

me.DataGridView1.Rows.Item(x).Selected = true

where x is the row you want to select

--
--ewok
MCSA+M,MCSE, MCSD, MCDBA,MCITP
"Karl Rhodes" wrote:
I have a datagridview which is populated via a datatable.

What I would like to dynamically set a selected row and have that row
show up in the datagridview and not have to manually scroll to find the
selected row.

I had a look for all kind of "datagridview1.rows(i).focus" but there
doesnt seem to be anything. Can anyone help? I know this must be quite
simple to do but cant find it.

Jun 1 '06 #2

P: n/a
Thanks ewok, but i did try this.

While it selects the row ok, it doesnt bring this selected row to the
datagrid 'window'. This means if the datagrid is long and the selected
row is the last row, only the top rows are still visible. I would like
to have the datagrid automatically scroll so the selected row is
visible in the datagrid pane
ewok66 wrote:
try:

me.DataGridView1.Rows.Item(x).Selected = true

where x is the row you want to select

--
--ewok
MCSA+M,MCSE, MCSD, MCDBA,MCITP
"Karl Rhodes" wrote:
I have a datagridview which is populated via a datatable.

What I would like to dynamically set a selected row and have that row
show up in the datagridview and not have to manually scroll to find the
selected row.

I had a look for all kind of "datagridview1.rows(i).focus" but there
doesnt seem to be anything. Can anyone help? I know this must be quite
simple to do but cant find it.


Jun 2 '06 #3

P: n/a
On 31 May 2006 02:39:36 -0700, "Karl Rhodes"
<go**********@tlbsolutions.com> wrote:
I have a datagridview which is populated via a datatable.

What I would like to dynamically set a selected row and have that row
show up in the datagridview and not have to manually scroll to find the
selected row.

I had a look for all kind of "datagridview1.rows(i).focus" but there
doesnt seem to be anything. Can anyone help? I know this must be quite
simple to do but cant find it.

Move the row you want to select to the top and then select it:

Me.DataGridView.FirstDisplayedScrollingRowIndex = SelIndex
Me.GridView.Rows(SelIndex).Selected = True

The selected row will be the first row displayed, or, will be a
visible row if the selected row is near the end of the displayable
rows.

Gene
Jun 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.