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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:45:27+00:00 2026-06-07T14:45:27+00:00

I am working on a UserControl for selecting special files, in this control there

  • 0

I am working on a UserControl for selecting special files, in this control there is a TreeView which gets populated with nodes when user selects some file. Also user can remove the files from this treeview!

I am using this control in a wizard form. In this wizard form there is a button named buttonNext and this button is disabled by default.

How can I create an event for the treeview in the usercontrol that when it gets populated it notify the next button in wizard form to get enabled and if user removes all files from that treeview it notify the button to get disabled again.

P.S: Selecting files (browser dialog and stuff like that) are all done within this usercontrol, so in my wizard form I have no access to the things that is going on in this component, but only I set the TreeView itself as public so I can read its nodes in my wizard form.

I know how to subscribe to events but never created any event myself 🙁

  • 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-07T14:45:32+00:00Added an answer on June 7, 2026 at 2:45 pm

    Declare events on your CustomControl:

    public event EventHandler DataPopulated;
    public event EventHandler DataRemoved;
    

    Common practice is creating protected virtual methods (for possible overriding them in descendant classes), named On<EventName> which will verify that event has attached handlers and raise event, passing required arguments:

    protected virtual void OnDataPopulated()
    {
        if (DataPopulated != null)
            DataPopulated(this, EventArgs.Empty);
    }
    

    NOTE: If you need to pass some data to event handlers, then use generic EventHandler<DataPopulatedEventArgs> delegate as event type, where DataPopulatedEventArgs is a class, inherited from EventArgs.

    Then just call this method just after your data was populated:

    treeView.Nodes = GetNodes();
    OnDataPopulated();
    

    Then just subscribe to this event and enable your next button:

    private void CustomControl_DataPopulated(object sender, EventArgs e)
    {
       buttonNext.Enabled = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a project with a setup like this: ASPX Page User Control 1
I am working in WPF and I am creating some userControl which some of
I'm working with WPF and I'm developing a complex usercontrol, which is composed of
I am working on a webform which has two UpdatePanels ; one inside UserControl
I'm working on a custom user control that essentially displays a name value pair
I am currently working within a WPF user control (the root element of my
Working in WPF, writing a custom user control. I am trying to change the
I'm working on a class that is derived from the UserControl class. This class
I am working on Windows Phone 7.1 application. I have a UserControl which has
A ChildClass user control I'm working with has a chain of parent classes, ultimately

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.