I know I've asked a similar question, but could someone post an example on how to manipulate a form through a separate class.
Just pass your form object into the class method parameter. Simple as that
???
http://csharpcomputing.com/Tutorials/calculator.htm
I'm trying to learn c# some atm, found that the other day may help.
Try this as a constructor:
using System.Windows;
[..]
public class ClassName(Form f);
Construct it from your main form as new ClassName(this);. Hint, the this keyword always references the instance of the class that you're in, unless you're in static, in which case.. it gives some big bad error.
Note that this is what Warrior said, but in a less verbose fashion.
Quote from: Joex86] link=topic=10262.msg130186#msg130186 date=1189912337]
Try this as a constructor:
using System.Windows;
[..]
public class ClassName(Form f);
Construct it from your main form as new ClassName(this);. Hint, the this keyword always references the instance of the class that you're in, unless you're in static, in which case.. it gives some big bad error.
In Java, static means class-specific (as opposed to object-specific); is it the same in C#? In C/C++, it has a completely different meaning (it prevents the linker from exporting the symbols beyond the scope of the .o file - although it does not prevent you from accessing that address in memory).
In Java, the static equivalent of
this is
ClassName. I'd assume that is the same in C#. In Java, I do not believe you can pass a class (which you can think of as a 'static object' if you don't want to be very technical) as a parameter, since it is not an object. I haven't tried, so I could be wrong about that, but what I said makes sense in OOD, so it should be the same in C#. Can anyone confirm?
Quote from: Camel on September 16, 2007, 05:25:53 AM
Quote from: Joex86] link=topic=10262.msg130186#msg130186 date=1189912337]
Try this as a constructor:
using System.Windows;
[..]
public class ClassName(Form f);
Construct it from your main form as new ClassName(this);. Hint, the this keyword always references the instance of the class that you're in, unless you're in static, in which case.. it gives some big bad error.
In Java, static means class-specific (as opposed to object-specific); is it the same in C#? In C/C++, it has a completely different meaning (it prevents the linker from exporting the symbols beyond the scope of the .o file - although it does not prevent you from accessing that address in memory).
In Java, the static equivalent of this is ClassName. I'd assume that is the same in C#. In Java, I do not believe you can pass a class (which you can think of as a 'static object' if you don't want to be very technical) as a parameter, since it is not an object. I haven't tried, so I could be wrong about that, but what I said makes sense in OOD, so it should be the same in C#. Can anyone confirm?
100% correct.