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. Windows Forms
  4. DataGridView ScrollBars [solved]

DataGridView ScrollBars [solved]

Scheduled Pinned Locked Moved Windows Forms
question
1 Posts 1 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.
  • P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #1

    I've been playing around with a DataGridView today. X| One of the things I noticed is that the ScrollBars behave differently when the thumb is dragged... The vertical ScrollBar scrolls the rows one whole row at a time. The horizontal ScrollBar scrolls the columns smoothly (which I suppose is usually the desired behaviour). Because all my columns are the same width (and narrow -- think of a Scrabble board implemented with a DGV) I would prefer to scroll a whole column at a time. Has anyone here achieved this? This isn't actually a big deal, just a "nice to have". (I expect someone at MS considered it a YAGNI.) Solution: In my earlier attempts, I had been trying to force the scrollbar to jump by the column width. Altering the HorizontalScrollingOffset directly to a value that is a multiple of the column width (X below) achieves the desired effect.

    private void
    dgResults_Scroll
    (
    object sender
    ,
    System.Windows.Forms.ScrollEventArgs e
    )
    {
    if ( e.ScrollOrientation == System.Windows.Forms.ScrollOrientation.HorizontalScroll )
    {
    this.dgResults.HorizontalScrollingOffset = e.NewValue / X * X ;
    }

    return ;
    

    }

    modified on Thursday, September 24, 2009 5:21 PM

    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