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 9094129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:16:40+00:00 2026-06-16T23:16:40+00:00

I have a lengthy context menu and I wanted to add some visual effect

  • 0

I have a lengthy context menu and I wanted to add some visual effect to the items (no, I don’t want to make a new renderer), so I just made a MouseEnter and MouseLeave event for one of the list items.
Now I want to extend this to all of the context menu items without making two separate events for each of the items…

Here is a short example of what I have at the moment:

Private Sub NewMenuItems_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewMenuItem1.MouseEnter, NewMenuItem2.MouseEnter, etc.
    MenuItem.ForeColor = Color.Red
End Sub

Private Sub NewMenuItems_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewMenuItem1.MouseLeave, NewMenuItem2.MouseLeave
    MenuItem.ForeColor = Color.Cyan
End Sub

The only thing that is different for each of the items is what comes before “.Forecolor”.
How do I make this work for all items at the same time?

  • 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-06-16T23:16:42+00:00Added an answer on June 16, 2026 at 11:16 pm

    If all of the instances of MenuItem are using the same event handlers then you can distinguish which one actually called it using the sender parameter, which should refer to the instance that invoked the event. So just cast sender to a MenuItem and that’s the one you’re looking for.

    Note that you should always be careful with casting, of course. In this case you’d want to make sure that it’s only a MenuItem which ever calls this handler, otherwise you’ll want to put in some error checking/handling with the cast in the event that another object invokes it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a context menu on a ListView. I would like to add a
I have a context menu with a few items. One of the items has
I have been unable to figure out how to keep a context menu open
I have made a context menu but I cant get the itemListener to work
I have 3 conditions (3 menu items in menu). In those 3 items, how
In an activity, I have two Text Views. In context menu, I have an
I have a wrapper div that contains arbitrary content (I don't know its length).
The book, Producing Open Source Software , suggests that it's better to have lengthy
I have a lengthy JavaScript file that passes JSLint except for used before it
I have a console app that performs a lengthy process. I am printing out

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.