troubleshooting Question

Static Method containing a Main form control

Avatar of perrytaylor
perrytaylor asked on
.NET ProgrammingC#
3 Comments1 Solution458 ViewsLast Modified:
I have a public static method that I am calling from a different class to make an adjustment to my main window gui.  In order for the other class to be able to use it I made it static.  But then I got an error saying that the form control that I am updating needs to be static.  How can I get around this to be able to update an existing control on my main gui?

code that is part of my window1 class that refers to my status bar in my WPF front end.
static public void status_bar_msg(string msg)
        {
            statusBar1.Items.Clear();
            TextBlock statusLabel = new TextBlock();
            statusLabel.Text = msg;

            statusBar1.Items.Add(statusLabel);
        }

code that is in a class outside of my Window1 class that attempts to make a change to the front end.

 Window1.status_bar_msg("Excel Export took " + Math.Round(diff.TotalSeconds, 2).ToString() + " secs.");


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros