1

I am trying to create a custom UI element: a panel, derived from the original panel, which is scrollable with special scrollbars (not the integrated ones) and has some other special abilities.

The actual problem is the scrolling. When I change the value of the custom scrollbar (e.g. scrolling), the panel-integrated scrollbars show up suddenly, although autoScroll = false. Leading to the unintended state where both scrollbars are visible, the integrated and my custom one.

Private Sub ScrollB_EvValueChanged(NewVal As Integer) Handles ScrollB.EvValueChanged
    Me.CleanPanel1.VerticalScroll.Value = NewVal
End Sub

How can I assign the new scrolling position (the new offset), determined by the custom scrollbar, to the panel without showing up panel-integrated scrollbars?

Sadly a panel (or usercontrol) with another panel on it and playing with the .Top and .Left properties of the inner panel to simulate scrolling is not an appropriate solution in my case.

Thank you for all your hints!

mookey
  • 85
  • 1
  • 10
  • Did you tried with `Me.CleanPanel1.VerticalScroll.Visible = False` – Hoh Sep 14 '14 at 15:27
  • rather than recreate the wheel (including tracking the scroll position and mouse navigation, keyboard nav) you could simply *add* whatever abilities you need to the existing control. Hard to imagine how you will scroll differently though. – Ňɏssa Pøngjǣrdenlarp Sep 14 '14 at 16:23
  • Is the visible property true? – Kashish Arora Sep 14 '14 at 16:45
  • Turning `Me.CleanPanel1.VerticalScroll.Visible` to `False` explicitly does not change anything. The integrated scrollbar pops up for a millisecond when a value is assigned to `Me.CleanPanel1.VerticalScroll.Value`. How can I avoid this behavior? – mookey Sep 14 '14 at 17:20
  • @Plutonix the custom scrollbar is already made by me and reacts on key presses, mouse-wheel, etc.. now just the binding to the panels -let's say- scroll-offset is causing problems.. – mookey Sep 14 '14 at 17:22
  • Setting *Me.CleanPanel1.VerticalScroll.Value = NewVal* is not exactly *custom scrollbar* is it? Custom means make everything yourself not calling the *VerticalScroll bar* of the control. – γηράσκω δ' αεί πολλά διδασκόμε Sep 14 '14 at 22:56

1 Answers1

0

'I've been looking for methods of doing this all over, most of it is way more complicated than it needs to be, or you gotta write a whole dang program just to remove the bars to scroll. Anyhow, here's a quick, effective, neat method of doing this (since I was having trouble finding anything, I'll post it. 'e.delta detects a mouse wheel tick, if greater than 0, scroll up, less than 0 scroll down. ' the -91 part deducts some of the panel overhang (adjust as needed) 'I have buttons in this project that are 50 tall, so this scrolls perfectly for me. 'the nested if statements where there is no code (just else), tells the program to stop 'do nothing if a border is near by. The bottom of my panel, while scrolling, doesn't 'stop when the bottom of the panel (which is hanging off the bottom of the form quite 'some ways) reaches the bottom of the form, this can be adjusted by altering the 700 constant.

Private Sub DaddyPanel_MouseWheel(sender As Object, e As MouseEventArgs) Handles DaddyPanel.MouseWheel

        If e.Delta < 0 Then
            If (-DaddyPanel.Height - 91) > (DaddyPanel.Location.Y - 700) Then
            Else
                TextBox1.Text = DaddyPanel.Height & " " & DaddyPanel.Location.Y
                DaddyPanel.Location = DaddyPanel.Location + New Point(0, -50)
            End If

        Else
                If DaddyPanel.Location = New Point(0, 0) Then
            Else
                DaddyPanel.Location = DaddyPanel.Location + New Point(0, 50)
            End If
        End If
    End Sub
drpepper1324
  • 113
  • 9