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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:32:17+00:00 2026-05-17T20:32:17+00:00

I created a custom control which is actually just two labels inside a panel.

  • 0

I created a custom control which is actually just two labels inside a panel. I want to add an event so that when my custom control is clicked (which would really be clicking either one of the labels) it would return the properties of the whole control, I think that would mean that ‘sender’ in the event handler would be my custom control and not one of the lables. I don’t know if I made myself clear but what I mean is to treat the control as a ‘whole’ when it is clicked mmm anyway hope you get my point.

How can I do this?
Thanks in advance

  • 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-17T20:32:17+00:00Added an answer on May 17, 2026 at 8:32 pm

    What you can do is let the custom control consume the event of the label, and in the custom control implement a new event. Then, when the label event fires, you can fire your own event from the custom control.

    For example:

    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }
    
        public event EventHandler MyCustomClickEvent;
    
        protected virtual void OnMyCustomClickEvent(EventArgs e)
        {
            // Here, you use the "this" so it's your own control. You can also
            // customize the EventArgs to pass something you'd like.
    
            if (MyCustomClickEvent != null)
                MyCustomClickEvent(this, e);
        }
    
        private void label1_Click(object sender, EventArgs e)
        {
            OnMyCustomClickEvent(EventArgs.Empty);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created the custom control which is just a panel that I will
I've created a custom control which consists of two radio buttons with their appearance
I have created a custom control which derives from Panel. I use it to
I have created a simple Asp.Net custom control which automatically combines all the correct
Morning all, I've created a custom control with an image property. That image property
I've been trying to create a custom control that works exactly like the Panel
Lets pretend that for some reason I want to create a custom control that
I've created a custom control for MahTweets which simplifies/unifies the look of each update
I'm trying to create a custom control - a button - which will have
I created a custom autocomplete control, when the user press a key it queries

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.