vb.net mouse click

Hi,

How can I get the mouse to perform a right click instead of a left click when a user clicks the left mouse button in a specific datgridview column?
FCapoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne Taylor (webtubbs)Commented:
It'll be easier to handle the left click and perform your desired action when a cell in that column has been clicked.

You can do this in the Datagridview's CellMouseClick event and check the ColumnIndex...

Private Sub DataGridView1_CellMouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
        If e.Button = Windows.Forms.MouseButtons.Left And e.ColumnIndex = 4 Then
            'perform your action here
        End If
End Sub

Open in new window

0
FCapoAuthor Commented:
Hi,

the problem I'm having is when a user right clicks on a new row in the datagridview under a specific column, I set it to open up a form with various text strings, the user then chooses the string he wants by double clicking it, the form then closes and places the string he selected in the datagridview CELL that was last selected.

This works great on existing rows in the datagridview, but if they right click on a new row, the cell doesn't actually get selected, so when they choose the string, it will place it in the previous row's cell, just like is shown in the attached imagePic
0
Wayne Taylor (webtubbs)Commented:
You can determine if it's a new row that has been clicked by comparing e.RowIndex and DataGridView1.NewRowIndex in the CellMouseClick event. If they are equal, the new row has been clicked.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.