Monday, January 4, 2021

[VB.net][WFA] Add a right click menu in your application

Step 1) 

Drag a ContextMenuStrip from "Menu & Toolbars" catalog from toolBox to your form in design view.


Step 2) 

Click your "ContextMenuStrip" control and than double click the "Type here", type the text your want to display there.


Step 3) 

Add a mouseUp event to your form.


Step 4) 

Add script to your event handler for showing your contextMenuStrip :

Private Sub Form1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp

  If e.Button <> MouseButtons.Right Then Return

  ContextMenuStrip1.Show(Cursor.Position.X, Cursor.Position.Y)

End Sub

Where text in pink is property name of your "contextMenuStrip".

No comments :

Post a Comment