Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. datagrids

datagrids

Scheduled Pinned Locked Moved Visual Basic
question
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kristina_c
    wrote on last edited by
    #1

    I have a datagrid that displays information based on searches. When I run a search, the datagrid fills and I can scroll through the table. However, let's say I scroll down the list a little, and then decide to run another search. The datagrid fills with the new information and shows the top of the list, but the scroll box doesn't change. Then when I click on the scroll bar the table snaps to where it would be in relation to the scroll bar. How do I make the scroll bar move back to the top when the datagrid fills with new information? (This is on a Windows form btw) Puzzled...

    G 1 Reply Last reply
    0
    • K kristina_c

      I have a datagrid that displays information based on searches. When I run a search, the datagrid fills and I can scroll through the table. However, let's say I scroll down the list a little, and then decide to run another search. The datagrid fills with the new information and shows the top of the list, but the scroll box doesn't change. Then when I click on the scroll bar the table snaps to where it would be in relation to the scroll bar. How do I make the scroll bar move back to the top when the datagrid fills with new information? (This is on a Windows form btw) Puzzled...

      G Offline
      G Offline
      GrindAZ
      wrote on last edited by
      #2

      Take a look here http://www.syncfusion.com/FAQ/WinForms/FAQ\_c44c.asp#q895q or maybe try setting the current cell like this: Datarid.CurrentCell = New DataGridCell(0, 1)

      K 1 Reply Last reply
      0
      • G GrindAZ

        Take a look here http://www.syncfusion.com/FAQ/WinForms/FAQ\_c44c.asp#q895q or maybe try setting the current cell like this: Datarid.CurrentCell = New DataGridCell(0, 1)

        K Offline
        K Offline
        kristina_c
        wrote on last edited by
        #3

        thank you - looks like a good site, I'll be bookmarking that! I actually made a little subroutine that deletes the datagrid and then makes a new one. Then the scroll bar goes back to the top. But I will try this too...perhaps less code.

        G 1 Reply Last reply
        0
        • K kristina_c

          thank you - looks like a good site, I'll be bookmarking that! I actually made a little subroutine that deletes the datagrid and then makes a new one. Then the scroll bar goes back to the top. But I will try this too...perhaps less code.

          G Offline
          G Offline
          GrindAZ
          wrote on last edited by
          #4

          If you are just performing a new query and setting the results to the datagrid then in your routine where you set the datagrids datasource property, always set the datasource to nothing first. Private Sub FillGrid(dg As DataGrid) Dim ds As New DataSet '//Clear Any Data From The Grid dg.DataSource = Nothing '//Do Work To Get Data Here ' ' '//Fill The Grid With Data dg.DataSource = ds End Sub Just An Example. That way your really only had to add one line of code to clear the grid and scrollbar.

          K 1 Reply Last reply
          0
          • G GrindAZ

            If you are just performing a new query and setting the results to the datagrid then in your routine where you set the datagrids datasource property, always set the datasource to nothing first. Private Sub FillGrid(dg As DataGrid) Dim ds As New DataSet '//Clear Any Data From The Grid dg.DataSource = Nothing '//Do Work To Get Data Here ' ' '//Fill The Grid With Data dg.DataSource = ds End Sub Just An Example. That way your really only had to add one line of code to clear the grid and scrollbar.

            K Offline
            K Offline
            kristina_c
            wrote on last edited by
            #5

            Thank you so much! That did exactly what I wanted and it elminated the need for an extra subroutine.

            G 1 Reply Last reply
            0
            • K kristina_c

              Thank you so much! That did exactly what I wanted and it elminated the need for an extra subroutine.

              G Offline
              G Offline
              GrindAZ
              wrote on last edited by
              #6

              Your Welcome.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups