Page 1 of 1

MouseWheel?

Posted: Sun Jan 05, 2014 3:21 pm
by hungryhounduk
Hi Guys and Gals

Does anyone know how I can use the MouseWheel on my Mouse to Move an Item (say a Panel ) around my Form, ie, Left to Right?
I have looked at the Controls in VB and can't see anything that relates to the Mouse Wheel, But maybe it is just code that's needed and not a Control..

Any Help would be great and will get you a + Rep

Thanks in Advance

Hungry

Re: MouseWheel?

Posted: Sun Jan 05, 2014 4:42 pm
by XTechVB
Well i don't know about VB but in C# i use this code in the OnMouseWheel event of the panel, button, item, label etc...
Code: Select all
            if (e.Delta > 0)
            {
                //-- Mouse Wheel Moving UP
            }
            else if (e.Delta < 0)
            {
                //-- Mouse Wheel Moving DOWN
            }

Re: MouseWheel?

Posted: Sun Jan 05, 2014 5:15 pm
by hungryhounduk
Hey XTechVB

Ok thanks for that, I might see if i can do something similar to that for Vb

Cheers

Chris

Ps, I will let you know how i get on :)


Hey
Well i went online to convert it to VB
But I am still no Wiser
Code: Select all
'-- Mouse Wheel Moving UP
If e.Delta > 0 Then
		'-- Mouse Wheel Moving DOWN
ElseIf e.Delta < 0 Then
End If
So If anyone can Help me out I would really appreciate it, and I will give 50 Credits to anyone who can give me a working Example of a Form with a Panel being moved within it by the Middle Mouse Button :)

Chris

Re: MouseWheel?

Posted: Sun Jan 05, 2014 7:31 pm
by Bloodz_Ninja
the conversion seemed wrong so try this
Code: Select all
    
    If e.Delta > 0 Then
          // Mouse Wheel Moving UP
    ElseIf e.Delta < 0 Then
// Mouse Wheel Moving DOWN
    End If

Re: MouseWheel?

Posted: Sun Jan 05, 2014 8:19 pm
by CodenStuff
Moving a panel inside a form you could use this, just add it to your form code (assuming the panel is called Panel1):
Code: Select all
    Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
        If e.Delta > 0 Then
            Panel1.Left += 1
        Else
            Panel1.Left -= 1
        End If
    End Sub

Re: MouseWheel?

Posted: Sun Jan 05, 2014 9:11 pm
by hungryhounduk
Hey Cody

Cheers Fella, You are a Star :)
I have been trying to Fathom this out all afternoon and just a little bit of code like that did the trick, wwoooooooooooooohhhhhhhooooooooooooooo