Resize scrollbar in winforms

I want to resize the actual part of the bar / thumb of the scrollbar in winforms, but I cannot find a way to do this. The thumb is about 1/10 of the actual scroll area, no matter how many scrolls. The same is whether you need to scroll down along line 1 or 1000. I want its size to be adjusted depending on how much you need to scroll, or at least make it about 50% the size of the scroll area.

+3
source share
3 answers

Actually, I get it. this.vScrollBar1.LargeChange = this.vScrollBar1.Maximum / 2; changes the thumb to half the length of the track.

+2
source

This field has any property for scrolling settings, for example: AutoScrollMargin, AutoScrollMinSize, AutoScrollOffset , as well as HorizontalScroll and VerticalScroll , the last two properties are a virtual and horizontal scroll bar of the form, they also set some properties, such as Minimum, Maximum, SmallChange, LargeChange, Value.. If using all of these requirements does not meet your requirements, you should use a custom Scrollbar . Add a Scrollbar to the form and turn off the scroll bar of the form and set up your own scroll bar whenever controls are added to form or resize ...

+4
source

The size of the scroll bar control slider is directly proportional to the difference between the values โ€‹โ€‹of this ScrollBarName.Maximum control ScrollBarName.Maximum and ScrollBarName.LargeChange .

To use ScrollBarName.LargeChange you need a proportional offset value for ScrollBarName.Maximum so that the scrollbar control behaves as intended when used. The following example demonstrates how this displacement calculation is performed and how it is applied in the context of a practical application.

Offset calculation:

 ScrollBarName.Maximum = MyMaximum + MyLargeChange - 1 ' LargeChange Usage Offset Calcualtion 

Application Context:

 '*** Using Simplified Values To Avoid Confusion *** Dim ScrollBarName As New VScrollBar ' Or HScrollBar Control Dim MyMaximum As Integer = 100 ' Your "off screen" calculated value Dim MySmallChange As Integer = 10 ' MySmallChange <= MyLargeChange <= MyMaximum Dim MyLargeChange As Integer = 50 ' MyLargeChange <= MyMaximum (Example produces thumbar sized {(MyLargeChange / ScrollBarName.Maximum) %} Clientsize.width Me.controls.add(ScrollBarName) ' Add Your Control ScrollBarName.Dock = DockStyle.Right ' Dock bottom for HScrollBar ScrollBarName.SmallChange = MySmallChange ScrollBarName.LargeChange = MyLargeChange ScrollBarName.Maximum = MyMaximum + MyLargeChange - 1 ' LargeChange Usage Offset Calcualtion ScrollBarName.Value = 20 ' The scrollBar movement value whereby ScrollBarName.Value <= MyMaximum 
+1
source

Source: https://habr.com/ru/post/912477/


All Articles