Solved

C# Windows App VS2008 - Problem with passing values to a static method?

Posted on 2008-06-17
1
202 Views
Last Modified: 2013-12-16
C# Windows App VS2008 - Problem with passing values to a static method?

I have one class that I want to pass a string to a method in another classes textbox. When I make the method in the other class static I can see it but with the method it wont see its own textbox (txtMyBox). When I make the method non static it can see the textbox but the other class cannot see the method?!

Seems like a catch 22? Any help appreciated. I suspect fundametal failure to comprehend. See some attached code if it helps.


Tring to call the method...
 

frmUnmigrated.reportUnmigarted(unmigratedFiles.ToString());
 

trying to pass to this method in second class but when static wont see its own form objects (trying to update a textbox)
 

namespace Share_Check

{

    public partial class frmUnmigrated : Form

    {

        public frmUnmigrated()

        {

            InitializeComponent();

            Global.frmUnmigratedRef = this;

        }

        public static String reportUnmigarted(String files)

        {

            // <<<<-------- I want to put txtBox.Text = files; here but NO!! wont see the text box

            return "Done";

        }

        

    }

}

Open in new window

0
Comment
Question by:Karl66
1 Comment
 

Accepted Solution

by:
Karl66 earned 0 total points
ID: 21807237
I ended up having to do this...

        public static String reportUnmigrated(String files)
        {
            Share_Check.Global.frmUnmigratedRef.txtUnmigrated.Text = files;
            return "Done";
        }
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now