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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:11:20+00:00 2026-06-18T11:11:20+00:00

I need to make classes in my program to start a chain of events

  • 0

I need to make classes in my program to start a chain of events to write a text in a textbox.
I know that the classes shouldn’t know about the form. how to do that? take into account the fact that i’ll instalize the class on another thread.

I’ve already tried making an interface which connects the classes and make method on the form with ref parameters.

*update:*you all misunderstood me- i was talking about events not in proggraming. all i need is add text to textbox from another class. i added the “chain of events” to define it from simila questions, in them they’ve tried to change the text drectly from the class. sorry.

  • 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-18T11:11:21+00:00Added an answer on June 18, 2026 at 11:11 am

    Without knowing enough about your application I’ll suggest that what you need is to invoke an event in the class that is handled by the form. What happens is like this:

    1. Class has an event.
    2. Form starts up and instantiates class.
    3. Form assigns a handler to the event in the class.
    4. Class does whatever it needs to do, until it reaches the point where it needs to communicate with the form.
    5. Class raises the event.
    6. The handler in the form gets executed and the textbox changes.

    So in the code of the class you’ll need to add some definitions:

    public delegate void FinishedEventHandler(object sender, string ValueToReturn);
    public event FinishedEventHandler Finished;
    

    The first is a delegate with the signature of the event. By convention the first argument is always a reference to the instance of the class itself, and the rest are the values you want to return. The second is the actual event.

    Now, in the function that does whatever processing the class does we need to raise the event when appropriate:

    void DoSomething()
    {
        .
        .
        .
        if(Finished!=null) Finished(this, "some value");
    }
    

    The if clause is used to make sure that someone is actually handling our event, otherwise we might get an exception.

    Now let’s take a look at the form. We need to add a function that handles the event. It needs to have the same signature as the delegate we defined earlier. Within that function we do whatever changes we need to the form in light of the values we get back:

    private void FinishedEventHandler(object sender, string ValueToReturn)
    {
        TextBox1.Text = ValueToReturn;
    }
    

    Now we’re ready to use all that plumbing we just created. First we add the handler to the event, then we can call the class’s processing functions.

    MyClass.Finished += FinishedEventHandler;
    MyClass.DoSomething();
    

    Here’s a more detailed tutorial:

    http://msdn.microsoft.com/en-us/library/aa645739(v=vs.71).aspx

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

Sidebar

Related Questions

Are anonymous inner classes private by default? Can I make them public? I need
I need make some action (dump statistical data) before the Dart program ends. The
Need to make certain Ruby strings in my program to be immutable. What is
For a program i'm writing I need to marshal ActionScript classes to a format
I'm trying to make a program that can load an unknown set of plugins
I am about to start my newest project, it is basicly an application that
I'm implementing Cloneable with one of my classes, and I need to make a
I'm writing a program which will need to create and make use of an
Current project: To make a time program in C# with two classes Time and
I am trying to make a program that takes input from a file and

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.