I want to be able to access the control members of a form from within a
class. So i designed my constructor something like this
Form1 parentForm;
ClassName ( Form1 frm )
{
parentForm = frm;
}
But when I try and pass the form to the class it errors.
ClassName myClass( this );
What am I doing wrong ???
Cheers
Alberto Poblacion - 26 Dec 2007 14:59 GMT
>I want to be able to access the control members of a form from within a
>class. So i designed my constructor something like this
[quoted text clipped - 11 lines]
>
> What am I doing wrong ???
I think that what you want to do is this:
ClassName myClass = new ClassName(this);
It will only work if it is done inside Form1, since otherwise "this"
would not be of the adequate type to pass to the constructor that you
defined.
Jon Skeet [C# MVP] - 26 Dec 2007 15:12 GMT
<snip>
> But when I try and pass the form to the class it errors.
>
> ClassName myClass( this );
>
> What am I doing wrong ???
Well, that's not the syntax used for a constructor call. You need:
ClassName myClass = new ClassName(this);

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Ignacio Machin ( .NET/ C# MVP ) - 26 Dec 2007 16:42 GMT
Hi,
You need to get a book of C# , some basic stuff like syntax, etc.

Signature
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
>I want to be able to access the control members of a form from within a
>class. So i designed my constructor something like this
[quoted text clipped - 15 lines]
>
> Cheers