473,394 Members | 1,663 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

passing a form to a constructor.

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


Dec 26 '07 #1
3 1176
"Just Me" <news.microsoft.comwrote in message
news:ew**************@TK2MSFTNGP04.phx.gbl...
>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 ???
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.

Dec 26 '07 #2
<"Just Me" <news.microsoft.com>wrote:

<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);

--
Jon Skeet - <sk***@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
Dec 26 '07 #3
Hi,
You need to get a book of C# , some basic stuff like syntax, etc.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Just Me" <news.microsoft.comwrote in message
news:ew**************@TK2MSFTNGP04.phx.gbl...
>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


Dec 26 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Guy | last post by:
Hi, I'm working in vb.net and have one form that creates a second form. I need the first form pass info to the second form. I tried using a shared property in the first form and got this error...
2
by: Curtis Justus | last post by:
Hi, I currently have a control that is on a form and I want to pass that exact instance of the control to another form (a child form that appears on a button click). The control has state,...
2
by: Michael C | last post by:
What's the best wat to pass data between two separate forms. For instance, Form1 invokes Form2 like this: Form z = new Form2(); z.Show(); How can I pass back strings and boolean values from...
3
by: JJ | last post by:
Hi, I need to pass a dataset to another win form along with a SqldataAdapter. I don't want to recreate the SqlDataAdapter again either. So to pass to another Win form in my windows form app, do...
8
by: Chris Thunell | last post by:
I would like to open a form and pass variables to the new form as needed. Example: Dim myform as new chrisform myform.visible = true But what i would like is Dim myform as new...
3
by: lavu | last post by:
How would I pass parameters from the main form to my subform at load time. I use Activator.CreateInstance to create the subform. Thanks in advance. Ps: I tried googling for this but found no...
4
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh...
6
by: raylopez99 | last post by:
This thread is about how variables or parameters (including objects) are passed between forms (namely, using parameterized constructors, e.g., to pass an int between forms (e.g., a calling form and...
6
by: gggram2000 | last post by:
I'd like to know how I go about passing two variables from one form to the next. For example, I can pass a variable like this: This demonstrates how to pass a variable to a form when the form is...
1
by: brixdotnet | last post by:
Hi there! I made own user control for displaying and editing content. In Page_Load of this control is checked if user is authorized for editing if so, button for editing is shown, otherwise...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.