borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (swipe card)Next Topic (Best/simplest way to save user input) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : Right click to work same way as left click
Poster Message
DianeJ
Level: Protégé

Registered: 01-08-2006
Posts: 5

icon Right click to work same way as left click

Is it possible to set the properties of a button to act the same way as a click event but with the right click instead of the left.  What I am trying to do is if the button is clicked (left click) the total of a text box is subtracted by one (this part is working fine) but what I also want to do is if the same button is right clicked then 1 is added to the text box.

07-09-2006 at 10:00 PM
View Profile Send Email to User Show All Posts | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: Right click to work same way as left click

Hello. Offhand, in VB6, you could deal with the MouseDown event. It has an argument to determine whether is clicked the left or right button, as following
' === VB6 code ===
Private Sub btnTest_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' see help of MouseDown event for Button's argument avaliable values
    If Button = 2 Then MsgBox "Right-click on command button"
End Sub

Yet, the KeyDown event with the KeyCode argument set on vbKeyRButton seems not working.
This principle applies to VB6, so have a look if there is a similar property in VB.Net

Hope it helps

____________________________
Real Programmer can count up to 1024 on his fingers

07-09-2006 at 10:22 PM
View Profile Send Email to User Show All Posts | Quote Reply
shahidmojid
Level: Professor

Registered: 09-05-2002
Posts: 85
icon Re: Right click to work same way as left click

Also, you can use

    Private Sub btnTest_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnClose.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Right Then
           'code goes here
        else
             if e.button = windows.forms.mousebuttons.left then
                'code goes here
           endif
        End If
    End Sub

13-09-2006 at 06:33 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB.Net : Right click to work same way as left click
Previous Topic (swipe card)Next Topic (Best/simplest way to save user input) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder