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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:22:10+00:00 2026-06-10T14:22:10+00:00

I have a button comprised of a panel, picturebox and label. I have disabled

  • 0

I have a “button” comprised of a panel, picturebox and label.

I have disabled the picturebox and label to keep the MouseEnter (and back color) active.
However, the disabled label has the usual faded text – is there a way to keep the label enabled but ignore mouse events as it does when disabled?

Private Sub panelBackup_MouseEnter(sender As Object, e As EventArgs) Handles panelBackupButton.MouseEnter
    Dim btn As Panel = DirectCast(sender, Panel)
    btn.BackColor = Color.Gray
End Sub

Private Sub panelBackup_MouseLeave(sender As Object, e As EventArgs) Handles panelBackupButton.MouseLeave
    Dim btn As Panel = DirectCast(sender, Panel)
    btn.BackColor = Color.LightGray
End Sub
  • 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-10T14:22:11+00:00Added an answer on June 10, 2026 at 2:22 pm

    Set the same event also for the label

    Private Sub panelBackup_MouseEnter(sender As Object, e As EventArgs) 
                       Handles panelBackupButton.MouseEnter, Label1.MouseEnter 
        Dim btn As Panel = TryCast(sender, Panel) 
        if Not btn Is Nothing then 
            btn.BackColor = Color.Gray 
        else 
            Dim lbl As Label = TryCast(sender, Label)
            lbl.BackColor = Color.Gray 
        end if
    End Sub
    
    Private Sub panelBackup_MouseLeave(sender As Object, e As EventArgs) 
                       Handles panelBackupButton.MouseLeave, Label1.MouseLeave 
        Dim btn As Panel = TryCast(sender, Panel) 
        if Not btn Is Nothing then 
            btn.BackColor = Color.LightGray 
        else 
            Dim lbl As Label = TryCast(sender, Label)
            lbl.BackColor = Color.LightGray 
        end if
    End Sub 
    

    Also I have removed the DirectCast because you could use directly the panelBackup.BackColor property (otherwise you need to add unnecessary additional logic to differentiate the events fired by the panel or by the label.

    EDIT: Seeing your comment I have changed the methods reintroducing the cast, but using TryCast to avoid exceptions when the event is raised by a label.
    I should mention that probably is possible to TryCast to a generic Control instead of specific Panel or Label because BackColor is a property inherited from the base class (Control)

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

Sidebar

Related Questions

I have a UITableView comprised of custom UITableViewCells with some text and a button
I have a buttonset that is mostly comprised of single characters for each button.
I have a new problem with a Form and the BACK button. Take this
I have button which post values of form to url but during post i
I have button that a user selects and I pop up a AlertDialog to
I have button in my application that opens android contact application for choose contact
I have button, which fires an event, that deletes a record from the database.
I have one issue with Datetime Picker In my firstview i have button.If i
I have one issue with UInavigationcontroller In my firstview i have button.If i click
I have a button that can have a focus css class associated with it

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.