Solved

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

Posted on 2008-06-17
1
204 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

19 Experts available now in Live!

Get 1:1 Help Now