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

  • Home
  • SEARCH
  • 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 6600231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:35:42+00:00 2026-05-25T18:35:42+00:00

My mind somehow is stuck in a loop of errors. I don’t want to

  • 0

My mind somehow is stuck in a “loop of errors”. I don’t want to waste time any more with endless trial and error, so I better ask here:

I have a Windows-Form (.NET, C++) like following. The simplified version here only has a RichTextBox, a static and a non-static member function. Appending Text to the RichTextBox from the non-static function “nonstaticFunc()” works as expected.

But how can I do this from the static member function “staticFunc()“? I tried several approaches proposed in this forum on how to call non-static functions from static functions, but somehow I couldn’t figure out how to do this.

public ref class Form1 : public System::Windows::Forms::Form
    {

    public:
        Form1()
        {
            InitializeComponent();
        }

    protected:
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }

    protected: 

    private:
        System::ComponentModel::Container ^components;

    private: System::Windows::Forms::RichTextBox^  myTextBox;




    System::VoidInitializeComponent( System::Void )
    {
        System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
        this->myTextBox = (gcnew System::Windows::Forms::RichTextBox());
    }

    public: System::Void nonstaticFunc( System::Void )
    {
        this->myTextBox->AppendText( L"Append this...\n" );
    }

    public: static System::Void staticFunc( System::Void )
    {
        // How do I AppendText here??
        // Not working: this->myTextBox->AppendText( L"Append this...\n" );
    }
}

Thanks for every little bit of help! Appreciated a lot!

  • 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-25T18:35:42+00:00Added an answer on May 25, 2026 at 6:35 pm

    You need to work out which text box you’re interested in. What if there are two visible forms? You don’t have enough context.

    Now you could keep a static member to keep track of “the one true form” – or you could take the textbox or form as a parameter… but fundamentally you need to have that context somehow.

    Why do you want to do this from staticFunc anyway? Why can the caller not call the method on the appropriate form? Once you understand the problem – why it won’t work – you should be able to think about the most appropriate change. We can’t really tell you that, as we don’t have enough information.

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

Sidebar

Related Questions

I don't mind so much about pirating etcetera, but I want to ensure that
I don't mind most of the way that VS2005 auto-indents (or auto-formats) my C++
Today, during some other somehow related work, came across my mind the following question:
I don't have time to write a perl or anything like that nor do
Somehow my mind went far away from the current problem and I made a
My mind is somehow blank. How do I do this: I have a RegistrationController
I have found an error in my code that somehow having html code with
In my mind, both modal dialogs and lightboxes serve the same purpose. It seems
Trying to get my mind around google protobuf. I found some implementation of protobuf
Update 3 : Never mind. I kinda got what I was looking for. The

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.