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

  • Home
  • SEARCH
  • 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 7848773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:19:33+00:00 2026-06-02T18:19:33+00:00

I have 40 buttons in a application that I need custom hovers that will

  • 0

I have 40 buttons in a application that I need custom hovers that will show in a status field. I have made a function for adding a certain message and one to remove, so upon a hover, it calls the function, and same with leaving the button.

I want 40 different messages and one way of doing that is to check which button is being hovered over by the mouse.

if(button1.hovered == true){
  string message = "scenario1";
}
elseif(button2.hovered == true){
  scenario2...etc
}

Is there a way to check if hovered? and check it in a if statement?

ive decided to add more info so it might be easier to get my point.

add message to listview when mouse hoover.

    void messAdd(object sender, EventArgs e)
    {


        string now = DateTime.Now.ToString("M/d/yyyy") + " - " + DateTime.Now.ToString("HH:mm:ss tt");
        string message = "message 1";
        found = false;

        ListViewItem item = new ListViewItem(message);
        foreach (ListViewItem z in listView1.Items)
        {
            if (z.Text == message)
            { found = true; }
        }

        if (found == false)
        {
            item.SubItems.Add(now.ToString());
            listView1.Items.Add(item);
            listView1.EnsureVisible(item.Index);
        }
        else
        {
            DeleteIfNecessary(message);
        }
    }

delete message from listbox when mouse leave:

    void messdel(object sender, EventArgs e)
    {


        string message = "message 1";
        found = false;

        ListViewItem item = new ListViewItem(message);
        foreach (ListViewItem z in listView1.Items)
        {
            if (z.Text == message)
            { found = true; }
        }

        if (found == true)
        {
            DeleteIfNecessary(message);
        }

    }

I can make 4 of these functions for each buttons, but since i need 40 different messages, stupid yes, but there is no way to send a message argument through the function, so i need to use the if test and check witch button is hovered and then output the message to that specified button. and im using visual studio and windows forms, sorry for not mentioned.

  • 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-02T18:19:36+00:00Added an answer on June 2, 2026 at 6:19 pm

    There is a Control.MouseHover event. You can implement:

    private void button_MouseHover(object sender, System.EventArgs e)
    {
        doSomething(sender);
    }
    

    and for all of your buttons, set event handler for MouseHover to button_MouseHover in IDE, or do it in code:

    this.button1.MouseHover += new System.EventHandler(this.button_MouseHover);
    

    By checking the sender parameter you can know which button is calling the event handler.

    Update

    According to your update in the question, I think you can just use messAdd as the event handler for MouseEnter event for all of your buttons, and use messdel as the event handler for MouseLeave. Again, you don’t need to create a copy of these two methods for all of your buttons, you just need to assign the same event handler method for all the buttons, and check sender to know who is calling the event handler – then creating different messages.

    The sender is your Button object. Just cast it to a Button and access what you want (text, tag, name, etc.) to know which Button is trying to add/remove message on the list view.

    Update 2

    Button button = sender as Button;
    if (button == null) {
        // not a button, do nothing
        return;
    }
    
    string message = String.Empty;
    if (sender.Equals(button1)) {
        message = "message1";
    } else if (sender.Equals(button2)) {
        message = "message2";
    } ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that has a list of buttons and has customized tooltips.
I have a group of radio buttons in my Swing application that have a
In my application I have several activities, the main screen has 4 buttons that
I have a dynamic application that need to create a window interface with checkbox.
I have an application where I need to have a custom setting page. In
I have a mvvm(model view viewmodel) silverlight application that has several views that need
My application has a few portions that have really big buttons (640x130, 230x150, etc.)
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
I have a Java swing application with a button that produces a popup window
In Application i have two buttons in which one button is used as a

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.