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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:23:31+00:00 2026-05-10T18:23:31+00:00

I have a .NET UserControl (FFX 3.5). This control contains several child Controls –

  • 0

I have a .NET UserControl (FFX 3.5). This control contains several child Controls – a Panel, a couple Labels, a couple TextBoxes, and yet another custom Control. I want to handle a right click anywhere on the base Control – so a right click on any child control (or child of a child in the case of the Panel). I’d like to do it so that it’s maintainable if someone makes changes to the Control without having to wire in handlers for new Controls for example.

First I tried overriding the WndProc, but as I suspected, I only get messages for clicks on the Form directly, not any of its children. As a semi-hack, I added the following after InitializeComponent:

  foreach (Control c in this.Controls)   {     c.MouseClick += new MouseEventHandler(       delegate(object sender, MouseEventArgs e)       {         // handle the click here       });   } 

This now gets clicks for controls that support the event, but Labels, for example, still don’t get anything. Is there a simple way to do this that I’m overlooking?

  • 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. 2026-05-10T18:23:32+00:00Added an answer on May 10, 2026 at 6:23 pm

    If the labels are in a subcontrol then you’d have to do this recursively:

    void initControlsRecursive(ControlCollection coll)  {      foreach (Control c in coll)        {          c.MouseClick += (sender, e) => {/* handle the click here  */});          initControlsRecursive(c.Controls);      }  }  /* ... */ initControlsRecursive(Form.Controls); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net usercontrol that contains a jQuery UI Dialog Control. All works
I have an ASP.Net UserControl that looks like this: <%@ Control Language=C# AutoEventWireup=true CodeBehind=WebUserControl1.ascx.cs
I have an ASP.NET user control that contains a text box control and a
I have an ASP.NET web form that has a container usercontrol that hosts several
I have asp.net usercontrol that is including some js script like this <script type=text/javascript
I have created .Net usercontrol in C#. it is graphical control with a text
I have a for which is built within an ASP.net usercontrol. This form is
I have created my first asp.net UserControl that I will use in several places
In The Page_Load event of an ASP.NET USercontrol, I have the following Code: If
I have a UserControl in my Asp.net project that has a public property. I

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.