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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:34:48+00:00 2026-05-26T10:34:48+00:00

I have a custom usercontrol and I want to do something relatively simple. When

  • 0

I have a custom usercontrol and I want to do something relatively simple.

When ever a numeric up down in that usercontrol’s value changes, have the main form update a display window.

This is not a problem if the NUD was not in a usercontrol but I can’t seem to figure out how to have the event handled by the mainform and not the usercontrol.

  • 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-26T10:34:48+00:00Added an answer on May 26, 2026 at 10:34 am

    You need to create an event handler for the user control that is raised when an event from within the user control is fired. This will allow you to bubble the event up the chain so you can handle the event from the form.

    When clicking Button1 on the UserControl, i’ll fire Button1_Click which triggers UserControl_ButtonClick on the form:

    User control:

    [Browsable(true)] [Category("Action")] 
    [Description("Invoked when user clicks button")]
    public event EventHandler ButtonClick;
    
    protected void Button1_Click(object sender, EventArgs e)
    {
        //bubble the event up to the parent
        if (this.ButtonClick!= null)
            this.ButtonClick(this, e);               
    }
    

    Form:

    UserControl1.ButtonClick += new EventHandler(UserControl_ButtonClick);
    
    protected void UserControl_ButtonClick(object sender, EventArgs e)
    {
        //handle the event 
    }
    

    Notes:

    • Newer Visual Studio versions suggest that instead of if (this.ButtonClick!= null) this.ButtonClick(this, e); you can use ButtonClick?.Invoke(this, e);, which does essentially the same, but is shorter.

    • The Browsable attribute makes the event visible in Visual Studio’s designer (events view), Category shows it in the “Action” category, and Description provides a description for it. You can omit these attributes completely, but making it available to the designer it is much more comfortable, since VS handles it for you.

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

Sidebar

Related Questions

I have a Custom usercontrol that I want to enlarge. I tested this whit
I have a simple usercontrol that uses a simple custom panel where I just
I have one main windows form and within that form I have custom controls
I have a custom UserControl called (for instance) MyPanel, and I want to use
I have a custom control that inherits from UserControl , and I can't get
I have a custom UserControl that I created as a navigation menu that parses
I have a Custom UserControl . In that UserControl i have some buttons ,
I have a custom form that has 4 panels on it edges. I would
I have a custom UserControl that I am drawing using the GDI+. It is
We have a couple of DateTimePickers on a custom UserControl, on a Form. They

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.