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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:42:43+00:00 2026-05-26T03:42:43+00:00

I am trying to post text from a class into an active form and

  • 0

I am trying to post text from a class into an active form and I am having a little trouble figuring out how to do it. I have seen a bunch about using Invoking to post things across threads/forms but I can’t get my class to see any public functions in the activeform.

Example

// File: Form1.cs

namespace Form1
{
    public partial class Form1 : Form
    {
        public void SetText(string text)
        {
            this.Invoke((MethodInvoker) delegate { \\ Always requires invoke
                TextBox1.Text += text + "\n";
        });
    }
}

Then my second class that is being run in a second thread (because it is a long process)

// File: Class.cs

using Form1;

namespace Form1
{
    public void DoSomething() // Called in Form1
    {
        // Does stuff

        string TextToGoBack; // Has text when DoSomething runs

        // Here is where I get stuck
        Form form = Form1.ActiveForm;

        form.SetText(TextToGoBack); // SetText is not showing up here no matter what I do
    }
}

EDIT:

I would not be opposed to using custom events to accomplish the same thing, but I am having a tough time figuring those out as well.

  • 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-26T03:42:44+00:00Added an answer on May 26, 2026 at 3:42 am

    Form.ActiveForm returns a Form object, not the instance of your Form1 class, so does not have a SetText method.

    You could cast it to a Form1, but that would be brittle. I would pass the instance of Form1 to your DoSomething method.

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

Sidebar

Related Questions

I'm trying to post to a text box from anywhere in my program, regardless
Im trying to pass some values into a text box from a child page
I'm trying to post to the login form of an application on another subdomain
I'm trying to POST a http request using ajax, but getting a response from
I am trying to post a multi-part form using httplib, url is hosted on
I'm trying to post some information from a from do so some calculations, however
I am trying to build a import form for a CSV file into the
So I'm trying some code out to convert numbers into strings. However, I noticed
having some issues with a callback request form I'm trying to build for a
I am trying to inject an html string into a div, but am having

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.