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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:09:42+00:00 2026-05-15T13:09:42+00:00

Can someone please let me know by some code how I can call a

  • 0

Can someone please let me know by some code how I can call a function located in the Form class from another class?

Some code will be of great help!

thanks

EDIT: This is my current code

 public partial class frmMain : Form
 {
    //*******Class Instances*******
    ImageProcessing IP = new ImageProcessing();


    //********************
    public void StatusUpdate(string text)
    {
        tlsStatusLabel.Text = text;
    }//


    public frmMain()
    {
        InitializeComponent();            
    }//
}


class ImageProcessing
{

    private void UpdateStatusLabel(frmMain form, string text)
    {
        form.StatusUpdate(text);
    }//

   private UpdateLabel()
   {
        UpdateStatusLabel(frmMain, "Converting to GreyScale");
   }
}

the problem i am having is with frmMain.

  • 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-15T13:09:43+00:00Added an answer on May 15, 2026 at 1:09 pm

    A quick and dirty way is to create a reference of the MainForm in your Program.cs file as listed above.

    Alternatively you can create a static class to handle calls back to your main form:

        public delegate void AddStatusMessageDelegate (string strMessage);
    
        public static class UpdateStatusBarMessage
            {
    
            public static Form mainwin;
    
            public static event AddStatusMessageDelegate OnNewStatusMessage;
    
            public static void ShowStatusMessage (string strMessage)
                {
                ThreadSafeStatusMessage (strMessage);
                }
    
            private static void ThreadSafeStatusMessage (string strMessage)
                {
                if (mainwin != null && mainwin.InvokeRequired)  // we are in a different thread to the main window
                    mainwin.Invoke (new AddStatusMessageDelegate (ThreadSafeStatusMessage), new object [] { strMessage });  // call self from main thread
                else
                    OnNewStatusMessage (strMessage);
                }
    
            }
    

    Put the above into your MainForm.cs file inside the namespace but separate from your MainForm Class.
    Next put this event call into your MainForm.cs main class.

         void UpdateStatusBarMessage_OnNewStatusMessage (string strMessage)
         {
              m_txtMessage.Caption = strMessage;
         }
    

    Then when you initialise the MainForm.cs add this event handle to your form.

         UpdateStatusBarMessage.OnNewStatusMessage += UpdateStatusBarMessage_OnNewStatusMessage;
    

    In any UserControl or form associated with the form (MDI) that you want to call, just us the following…

         UpdateStatusBarMessage.ShowStatusMessage ("Hello World!");
    

    Because it is static it can be called from anywhere in your program.

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

Sidebar

Ask A Question

Stats

  • Questions 483k
  • Answers 483k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can't do pointer math on a void * pointer.… May 16, 2026 at 6:56 am
  • Editorial Team
    Editorial Team added an answer http://en.wikipedia.org/wiki/N-tier Microsoft Patterns & Practices site is a good resource… May 16, 2026 at 6:56 am
  • Editorial Team
    Editorial Team added an answer Concept of pipes. The fact that you can easily redirect… May 16, 2026 at 6:56 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.