K
Kim
Like
http://groups.google.dk/group/micro...csharp/browse_thread/thread/1ac280aaeed78de0/
and
http://groups.google.dk/group/micro...csharp/browse_thread/thread/f7fea4d944b12bf0/
am I trying to access something in a form in one class from another
class. And without luck
In my case I tried to change the Text of a Label. Here is my problem:
I'm using Microsoft Visual Studio 2005 Professional Edition.
I have 2 files (Form1.cs and Stuff.cs) with 1 class each and they are
in the same namespace. Form1.cs has a form with some elements, among
these, a label (Label1) and a button (Button1). I made an event so that
when I click on Button1 a fuction in Stuff.cs is called/run.
When the function in Stuff.cs is done, I want to signal this on the
form window by changing the Label1.Text.
I have tried making Label1 public (by default its private). See below,
note that this is inside Form1.cs.
public System.Windows.Forms.Label Label1
When I tried to change the text, from Stuff.cs, like this
Form1.Label1.Text= "NewText";
I got a compile error, "An object reference is required for the
nonstatic field, method, or property".
My question is then: How can I change something on an element in a form
in another class but while in the same namespace ?
http://groups.google.dk/group/micro...csharp/browse_thread/thread/1ac280aaeed78de0/
and
http://groups.google.dk/group/micro...csharp/browse_thread/thread/f7fea4d944b12bf0/
am I trying to access something in a form in one class from another
class. And without luck
In my case I tried to change the Text of a Label. Here is my problem:
I'm using Microsoft Visual Studio 2005 Professional Edition.
I have 2 files (Form1.cs and Stuff.cs) with 1 class each and they are
in the same namespace. Form1.cs has a form with some elements, among
these, a label (Label1) and a button (Button1). I made an event so that
when I click on Button1 a fuction in Stuff.cs is called/run.
When the function in Stuff.cs is done, I want to signal this on the
form window by changing the Label1.Text.
I have tried making Label1 public (by default its private). See below,
note that this is inside Form1.cs.
public System.Windows.Forms.Label Label1
When I tried to change the text, from Stuff.cs, like this
Form1.Label1.Text= "NewText";
I got a compile error, "An object reference is required for the
nonstatic field, method, or property".
My question is then: How can I change something on an element in a form
in another class but while in the same namespace ?