Results 1 to 6 of 6

Thread: How to add scrollbar to a flow layout control?

  1. #1

    Thread Starter
    Addicted Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    149

    How to add scrollbar to a flow layout control?

    Hi all,
    I added too many items to a flow layout control oriented from top to bottom, representing a sort of toolbox but now it contains too much components that I even unable to see them.

    - How can I add a vertical scroll bar to navigate only from top to bottom of flow layout panel?
    - Is there another proper control to do same thing, scrollable while subitems reach out of user monitor size?
    𝕬𝖒𝖎𝖗 𝕽. 𝕻𝖔𝖚𝖗𝖐𝖆𝖘𝖈𝖍𝖊𝖋𝖋

  2. #2
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,386

    Re: How to add scrollbar to a flow layout control?

    Hi Pourkascheff

    This'll do the trick.
    Code:
            FlowLayoutPanel1.HorizontalScroll.Visible = True
            FlowLayoutPanel1.VerticalScroll.Visible = True
    Add it to the form load subroutine. (Obviously you only need the vertical in this case)

    Poppa
    Last edited by Poppa Mintin; Dec 6th, 2022 at 06:32 AM.
    Along with the sunshine there has to be a little rain sometime.

  3. #3

    Thread Starter
    Addicted Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    149

    Re: How to add scrollbar to a flow layout control?

    Thank you sir. I only checked its properties in property grid and it wasn't available there but it seems in code things are in godmode.

    I added them both in Form1 load event but nothing happened. Neither of them are unavailable. Even mouse scroll does not work.
    Info: FlowLayoutPanel1 WrapContents is false.
    𝕬𝖒𝖎𝖗 𝕽. 𝕻𝖔𝖚𝖗𝖐𝖆𝖘𝖈𝖍𝖊𝖋𝖋

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    37,890

    Re: How to add scrollbar to a flow layout control?

    There are a few controls that don't expose all of their properties in the designer. In those cases, you do have to take care of it in code. Kind of annoying, but that's life.
    My usual boring signature: Nothing

  5. #5
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,386

    Re: How to add scrollbar to a flow layout control?

    Quote Originally Posted by pourkascheff View Post
    I added them both in Form1 load event but nothing happened. Neither of them are unavailable. Even mouse scroll does not work.
    Info: FlowLayoutPanel1 WrapContents is false.
    Ok, I made the assumption that your FlowLayoutPanel is named 'FlowLayoutPanel1'. The quote I've highlighted in red suggests that you have two FlowLayoutPanels, in order to have a vertical scroll bar in each, you will just need...
    Code:
     FlowLayoutPanel1.VerticalScroll.Visible = True
     FlowLayoutPanel2.VerticalScroll.Visible = True
    ...in your Form's Load Event.
    Again assuming the second FlowLayoutPanel is named 'FlowLayoutPanel2'.

    If your FlowLayoutPanels are contained within (say) a TableLayoutPanel you will need to adjust the commands to reflect that.

    I have tried this code with the FlowLayoutPanel's WrapContents =False, but that made no difference to either scroll bar in my test project.


    Poppa

    PS.

    Oh... I re-read your reply, maybe you meant you tried to add both scroll bars and (either) neither bar is available (there?) (or) both bars are unavailable. (not there)

    Pop.
    Last edited by Poppa Mintin; Dec 7th, 2022 at 08:27 PM. Reason: PS added.
    Along with the sunshine there has to be a little rain sometime.

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,535

    Re: How to add scrollbar to a flow layout control?

    Quote Originally Posted by pourkascheff View Post
    Thank you sir. I only checked its properties in property grid and it wasn't available there but it seems in code things are in godmode.

    I added them both in Form1 load event but nothing happened. Neither of them are unavailable. Even mouse scroll does not work.
    Info: FlowLayoutPanel1 WrapContents is false.
    Try adding this

    Code:
        Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown
            FlowLayoutPanel1.AutoScroll = False
            FlowLayoutPanel1.HorizontalScroll.Visible = True
            FlowLayoutPanel1.VerticalScroll.Visible = True
        End Sub
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width