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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:43:05+00:00 2026-06-13T00:43:05+00:00

I develop a WinForms UserControl in C#. The UserControl is essentially a composite control

  • 0

I develop a WinForms UserControl in C#.
The UserControl is essentially a composite control that consists of several child controls, e.g. a PictureBox, a CheckBox, a Label, etc.

From the calling code, I want to be able handling a Click event for my control.
However, I want the event raised if and only if the user clicks on a certain component of my control, e.g. the PictureBox. If the user clicks anywhere else within my control, the event should not be raised.

How can I do that?

  • 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-13T00:43:07+00:00Added an answer on June 13, 2026 at 12:43 am

    Assuming you are using WinForms.

    You should delegate a Click event from a pictureBox into your own event and then subscribe to it from the calling code.

    public class MyControl : System.Windows.Forms.UserControl
    {
        // Don't forget to define myPicture here
        ////////////////////////////////////////
    
        // Declare delegate for picture clicked.
        public delegate void PictureClickedHandler();
    
        // Declare the event, which is associated with the delegate
        [Category("Action")]
        [Description("Fires when the Picture is clicked.")]
        public event PictureClickedHandler PictureClicked;
    
        // Add a protected method called OnPictureClicked().
        // You may use this in child classes instead of adding
        // event handlers.
        protected virtual void OnPictureClicked()
        {
            // If an event has no subscribers registerd, it will
            // evaluate to null. The test checks that the value is not
            // null, ensuring that there are subsribers before
            // calling the event itself.
            if (PictureClicked != null)
            {
                PictureClicked();  // Notify Subscribers
            }
        }
        // Handler for Picture Click.
        private void myPicture_Click(object sender, System.EventArgs e)
        {
            OnPictureClicked();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winforms project that I want to develop a custom control for.
I need to develop several calendar type controls in winforms. These calendars are all
I am using C# + winforms to develop software. I have a UserControl which
I use winforms to develop a desktop application, and right now I plan to
I have to develop a application (Winforms-application) which is connected to a database within
i have some WinForms app (Framework to develop some simple apps), written in C#.
i have some WinForms app (Framework to develop some simple apps), written in C#.
I develop winforms app. One of my forms accepts user input and calls a
I'm done some WinForms work in C# but now moving to have to develop
I am planning to develop a UI control suite (open source) on .net because

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.