locked
Toolstripitem perform click ? RRS feed

  • Question

  • Hi All

    I winform with a DGV  I have a Memustrip with several ToolstripMenuItems (itemA , ItemB etc)

    ItemA has two subitems (ItemA1, ItemA2 )

    Clicking on DGV with the  Mouse Right button I would like to perform click on ItemA1.

    How to do it ?

    Tuesday, December 4, 2018 6:40 PM

Answers

  • Hi,

    see the code:

     Private Sub DataGridView1_MouseClick(sender As Object, e As MouseEventArgs) Handles DataGridView1.MouseClick
            If e.Button = MouseButtons.Right Then
                ItemAToolStripMenuItem_Click(sender, e)
            End If
        End Sub
    
        Private Sub ItemAToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ItemAToolStripMenuItem.Click
            MsgBox("123")
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Claudio111 Wednesday, December 5, 2018 7:13 PM
    Wednesday, December 5, 2018 2:41 AM

All replies

  • Hi

    Put the code from ItemA1 into a new Sub - then call it from anywhere you want.

    Of course, you would have replaced said code in the itemA1 click with a call to the new Sub


    Regards Les, Livingston, Scotland

    Tuesday, December 4, 2018 7:16 PM
  • Hi,

    see the code:

     Private Sub DataGridView1_MouseClick(sender As Object, e As MouseEventArgs) Handles DataGridView1.MouseClick
            If e.Button = MouseButtons.Right Then
                ItemAToolStripMenuItem_Click(sender, e)
            End If
        End Sub
    
        Private Sub ItemAToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ItemAToolStripMenuItem.Click
            MsgBox("123")
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Claudio111 Wednesday, December 5, 2018 7:13 PM
    Wednesday, December 5, 2018 2:41 AM