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. C#
  4. How to add a scrollbar to a custom control

How to add a scrollbar to a custom control

Scheduled Pinned Locked Moved C#
csharpcsscomtutorialquestion
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.
  • K Offline
    K Offline
    KeesVer
    wrote on last edited by
    #1

    Hello, I hope someone can point into the right direction with this question: I have a custom control which inherits from System.Windows.Forms.Control. This control requires scrolling but I'm unsure how to add the scrollbars. I see three options: - Add WS_HSCROLL and WS_VSCROLL flags in method CreateParams This feels like the right way to go because windows takes care of most of the scrollbar issues (like allignment). However, I found little support for this implementation in .Net. A method like SetScrollInfo is not part of the .Net implementation and can only be used after importing it from user32.dll. - Adding a VScrollBar and HScrollBar to the control. I think this could work, but extra code is needed to keep the scrollbars properly aligned and to adjust the client rectangle with the space occupied by the scrollbars. - Inheriting from System.Windows.Forms.ScrollableControl Because my component is like a grid and I want to handle painting, scrolling and most/all other events myself, I don't think this is the proper control to inherit from. Also, a ScrollableControl supports docking of other controls (a user can drag a button on the control) which I want to be dissabled. All your information is welcome. Regards, Kees Vermeulen info@kever.com

    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