Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

in your mousedown event try this:

 

 

 

If e.Button = MouseButtons.Right Then
msgbox("You pressed the right mouse button")
end if

Posted

can i do it outside a mouseDown event, in a different event I have?

Is there a another way to get whether the mouse button was clicked without using a parameter (such as 'e') from a method. Like something in: System.Windows.Forms....?

Posted
if have a 'chartDataClicked' from a 3rd party component. Thus I am not using the standard VB MouseDown event.

 

First, They're probobly extending the Mouse Down event into their own custom event. I'd think that something like this would still work.

 

Second, if it doesn't work (they didn't pass through the mouse down arguments, making their own custom arguments or created their own mouse down event from scratch) with their component, in runtime, a mousedown is still happening. I'm not a pro, I don't know which is happening first, the Mouse Down or chartDataClicked, but my money is on MouseDown. Just use the MouseDown, do some logic to make sure it's over the chart and send the mousedown information into a delegate or variable where your other event can take advantage of that knowledge.

Posted
if have a 'chartDataClicked' from a 3rd party component. Thus I am not using the standard VB MouseDown event.

 

Even though you are using a 3rd party control you can just have a mouse down event for your form. In this event you can "catch" which button was used and then use that in your ChartDataClicked event.

Posted
Even though you are using a 3rd party control you can just have a mouse down event for your form. In this event you can "catch" which button was used and then use that in your ChartDataClicked event.

 

 

do you mind providing a simple example?

Posted
do you mind providing a simple example?

 

Its really easy:

 

If e.Button = MouseButtons.Right Then
ClickFlag = True
end if 

 

Just declare ClickFlag as a boolean in your form level declarations:

 

dim ClickFlag as Boolean = False

 

If MouseDown's e.Button = MouseButtons.Right, then it sets ClickFlag to true.

 

In your event for chartClicked do a check for ClickFlag:

 

If ClickFlag = True
'Reset the variable for future use
ClickFlag = False
'Do other things you want to do when the chart is right clicked
End If

 

Of course after writing that, I think RightClickFlag or bRightClick might be a better name, but thats the gist of it.

Posted
do you mind providing a simple example?

 

 

Public rightMouseClicked As Boolean = False
  
   Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
       If e.Button = MouseButtons.Right Then
           rightMouseClicked = True
       End If
   End Sub

   Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
       If rightMouseClicked Then
           ' something    

           rightMouseClicked = False
       End If
   End Sub

 

the datagrid click has to be the datachartclick in your app

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...