Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

How do you dock a horizontal and verticle scroll bar control in the standard fashion?

This should be easy but I can not figure it out. I have a horizontal and verticle scroll bar control docked in the standard locations but can not get the little "square" area in the lower right corner. Instead, the arrow portion of one of the scroll bars will be in the corner instead. Other than hard coding them, does anybody know a quick way to get these to dock so that there is a blank square area in the lower right corner? Thanks in advance!
0
Amfab Steel
Asked:
Amfab Steel
  • 3
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Why are you using the ScrollBar controls manually?

Try setting the AutoScroll() property of your form to True.  The scrollbars will appear automatically when they are needed (if anything is outside the viewable area of your form).
0
 
Amfab SteelAuthor Commented:
I don't need to scroll the controls on a form so AutoScroll doesn't apply to my situation. The scroll bars are used to programatically "scroll" the output of vector data onto a stationary picturebox control.
0
 
SanclerCommented:
It depends what you mean by "Other than hard coding them".  Here's a sub I've used

    Private Sub doScrollBars()
        With vsb
            .Top = 0
            .Left = Me.ClientSize.Width - .Width
            .Height = Me.ClientSize.Height - hsb.Height
        End With
        With hsb
            .Top = Me.ClientSize.Height - .Height
            .Left = 0
            .Width = Me.ClientSize.Width - vsb.Width
        End With
    End Sub

The VerticalScrollBar (vsb) is anchored Right, the HorizontalSCrollBar (hsb) is anchored Bottom, and the sub is called in the Form's Load and Resize subs.

Roger
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Amfab SteelAuthor Commented:
Thanks for your comment Sancler. That is what I am planning to do if I can't find a way to use the built in docking feature. I would like to use the built in docking functionality in VB.NET so I don't have to manually resize the other controls like the picture box etc. I've loved not having to manually resize any controls in VB.NET and am getting VB 6.0 flashbacks now that I might have to do it programatically.
0
 
SanclerCommented:
I don't think you can do it with .Dock, but you can with .Anchor.  Here's the sub revised

    Private Sub doScrollBars()
        With vsb
            .Top = 0
            .Left = Me.ClientSize.Width - .Width
            .Height = Me.ClientSize.Height - hsb.Height
            .Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or AnchorStyles.Top
        End With
        With hsb
            .Top = Me.ClientSize.Height - .Height
            .Left = 0
            .Width = Me.ClientSize.Width - vsb.Width
            .Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
        End With
    End Sub

It would only need calling on Form Load.  

Or, if you want to set the sizes visually at design time retaining the clear square in the bottom right hand corner, you could also set the .Anchor values at design time.

Roger
0
 
Amfab SteelAuthor Commented:
Good enough for me. Thanks Roger!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now