scrollbar buttons-click?

PG74

New member
Joined
Aug 6, 2004
Messages
2
Programming Experience
Beginner
[font=verdana, arial, helvetica]Is it possible to create a sub that handles the scrollbar up and down-clicks for a vertical scrollbar. about the same way the button1_click-sub handles the button1-click?
I want different events to take place when I click the up or down button on the scrollbar besides that the bar scrolls of course.
[/font]
 

tresqboy

Member
Joined
Sep 6, 2005
Messages
7
Location
Manchester NH/Boston MA
Programming Experience
3-5
you can try subclassing a scrollbar control but iam not sure if you will be able to detect whether up or down button was clicked

But here is how i handle such a problem

VB.NET:
[color=#008000][font=Franklin Gothic Medium]'1-create a global value to track the previous value of scrollbar before click[/font]

[/color][font=Franklin Gothic Medium][color=#0000ff]Private[/color] previousValue [color=#0000ff]As[/color][/font][color=#0000ff][font=Franklin Gothic Medium]Integer[/font]

[/color][color=#008000][font=Franklin Gothic Medium]'2-on scrollbar event handler, find if the value increases or descreases[/font]

[/color][color=#008000][font=Franklin Gothic Medium]' INCREASE IN VALUE = button down was clicked[/font]

[/color][color=#008000][font=Franklin Gothic Medium]' DECREASE IN VALUE = button up was clicked[/font]

[/color][font=Franklin Gothic Medium][color=#0000ff]Private[/color][color=#0000ff]Sub[/color] VScrollBar1_ValueChanged([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color][color=#0000ff]Object[/color], [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] VScrollBar1.ValueChanged[/font]

[color=#008000][font=Franklin Gothic Medium]'determine if up/down button was clicked[/font]

[/color][font=Franklin Gothic Medium][color=#0000ff]If[/color] previousValue > [color=#0000ff]Me[/color].VScrollBar1.Value [/font][color=#0000ff][font=Franklin Gothic Medium]Then[/font]

[/color][color=#008000][font=Franklin Gothic Medium]'UP button was clicked[/font]

[/color][color=#008000][font=Franklin Gothic Medium]'do whatever[/font]

[/color][font=Franklin Gothic Medium][color=#0000ff]ElseIf[/color] previousValue < [color=#0000ff]Me[/color].VScrollBar1.Value [/font][color=#0000ff][font=Franklin Gothic Medium]Then[/font]

[/color][color=#008000][font=Franklin Gothic Medium]'DOWN button was clicked[/font]

[/color][color=#008000][font=Franklin Gothic Medium]'do whatever...[/font]

[/color][font=Franklin Gothic Medium][color=#0000ff]End[/color][/font][color=#0000ff][font=Franklin Gothic Medium]If[/font]

[/color][color=#008000][font=Franklin Gothic Medium]'make sure u set this reference value to the current scrollbar.value[/font]

[/color][font=Franklin Gothic Medium]previousValue = [color=#0000ff]Me[/color].VScrollBar1.Value[/font]

[font=Franklin Gothic Medium][color=#0000ff]End[/color][color=#0000ff]Sub[/color][/font]
[color=#0000ff]
[/color]
 
Top Bottom