Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6832925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:55:04+00:00 2026-05-26T22:55:04+00:00

I have Windows Form App. I have added Context Menu that appear when you

  • 0

I have Windows Form App. I have added Context Menu that appear when you right mouse click over the listbox. But some reason I could not figure out how to catch onClick event for ContextMenu- Menu-Item. In also need to grab item index from the listbox while user click on menu-item. If I am clicking the left mouse button i would use lstCustomer.SelectedItems(0).SubItems(2).Text, but I am not sure would it be the same case or not when user right clicks over the item and pick menu-item from Context Menu.

Dashboard.vb

Public Class Dashboard
  Private Sub Dashboard_Load(ByVal sender As System.Object, ByVal e As 
  System.EventArgs) Handles MyBase.Load
    LoadContextMenu()
End Sub


Private Sub LoadContextMenu()
    Dim contxMnu As New ContextMenu()
    Dim menuItem1 As New MenuItem()
    Dim menuItem2 As New MenuItem()

      contxMnu.MenuItems.AddRange(New MenuItem() {menuItem1, menuItem2})

      menuItem1.Index = 0
      menuItem1.Text = "Do Something 1"

      menuItem2.Index = 1
      menuItem2.Text = "Do Something 2"

      Me.ContextMenu = contxMnu
    End Sub

End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:55:05+00:00Added an answer on May 26, 2026 at 10:55 pm

    I’m not sure whether I understand exactly what you want to get. If it’s all about action that handles the Click event you can do something like this:

    Private Sub LoadContextMenu()
        Dim contxMnu As New ContextMenu()
        Dim menuItem1 As New MenuItem("Do Something 1", New EventHandler(AddressOf DoSomething1))
        Dim menuItem2 As New MenuItem("Do Something 2", New EventHandler(AddressOf DoSomething2))
    
        contxMnu.MenuItems.AddRange(New MenuItem() {menuItem1, menuItem2})
    
        Me.ContextMenu = contxMnu
    End Sub
    

    …and events are:

    Private Sub DoSomething1(sender As Object, e As EventArgs)
        ' do something 1 
    End Sub
    
    
    Private Sub DoSomething2(sender As Object, e As EventArgs)
        ' do something 2 
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Form app (4.0) that calls a Web Service (WCF) but
This is the situation. I have a windows form app that uses an access
I have an In-house windows form app that I would like to use Spell
I have a simple .NET 2.0 windows form app that runs off of a
JI have written a .NET C# Windows Form app in Visual Studio 2008 that
I have a Windows Form app that creates a window and monitors for entries
I have a simple windows form app that I need to get the file
I have a Windows Form app written in C#. Its job is to send
I have a windows form app written in C#. the main_form class instantiates an
I have a pretty basic windows form app in .Net. All the code is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.