Show dynamically selected row in datagridview

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Karl Rhodes

    #1

    Show dynamically selected row in datagridview

    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.

  • ewok66

    #2
    RE: Show dynamically selected row in datagridview

    try:

    me.DataGridView 1.Rows.Item(x). Selected = true

    where x is the row you want to select

    --
    --ewok
    MCSA+M,MCSE, MCSD, MCDBA,MCITP


    "Karl Rhodes" wrote:
    [color=blue]
    > 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.
    >
    >[/color]

    Comment

    • Karl Rhodes

      #3
      Re: Show dynamically selected row in datagridview

      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:[color=blue]
      > try:
      >
      > me.DataGridView 1.Rows.Item(x). Selected = true
      >
      > where x is the row you want to select
      >
      > --
      > --ewok
      > MCSA+M,MCSE, MCSD, MCDBA,MCITP
      >
      >
      > "Karl Rhodes" wrote:
      >[color=green]
      > > 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.
      > >
      > >[/color][/color]

      Comment

      • gene kelley

        #4
        Re: Show dynamically selected row in datagridview

        On 31 May 2006 02:39:36 -0700, "Karl Rhodes"
        <googlegroups@t lbsolutions.com > wrote:
        [color=blue]
        >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.[/color]


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

        Me.DataGridView .FirstDisplayed ScrollingRowInd ex = SelIndex
        Me.GridView.Row s(SelIndex).Sel ected = 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

        Comment

        Working...