MouseWheel?

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
6 posts Page 1 of 1
Contributors
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

MouseWheel?
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
Image
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: MouseWheel?
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
            }
You can find me on Facebook or on Skype mihai_92b
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: MouseWheel?
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
Image
User avatar
Bloodz_Ninja
Dedicated Member
Dedicated Member
Posts: 69
Joined: Sat Aug 25, 2012 3:20 am

Re: MouseWheel?
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
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: MouseWheel?
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
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: MouseWheel?
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
Image
6 posts Page 1 of 1
Return to “Coding Help & Support”