473,406 Members | 2,847 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,406 software developers and data experts.

Passing Form as parameter to non-form class

I want to show a dialog and when the form (dialog) is
closed, return to the calling form. The calling form
should then be able to pass the child form to another
object with the form as a parameter.

For example,

FormOptions formOptions = new FormOptions();
if (formOptions.ShowDialog(this) == DialogResult.OK)
{
ConfigurationManager configurationManager = new
ConfigurationManager();

configurationManager.saveConfiguration(formOptions );
}

formOptions.Dispose();

My ConfigurationManager has a method that looks like
this:
public void saveConfiguration(FormOptions formOptions)
{
ConfigurationData configurationData = new
ConfigurationData
(formOptions);
saveConfiguration(configurationData);
}

When I build this code I keep getting an error like this:
ConfigurationData.cs(20): The type or namespace
name 'FormOptions' could not be found (are you missing a
using directive or an assembly reference?)

These classes are all within the same namespace.

Is it possible to pass the form object to another class?
Or do I need to extract values from the form and pass
them on to my ConfigurationManager?

I've even tried qualifying the FormOptions class in my
parameter list as SCT.FormOptions. "SCT" is my namespace.

Intellisense doesn't see any of my forms when I try to
qualify the FormOptions class.

I suppose this is a pretty simple solution. But, it's
frustrating.
Nov 15 '05 #1
4 4849
Ron,

They might all be in the same namespace, but is the form and the class
in the same assembly? If not, then you have to make sure that the class
that the form is being passed to has a reference to the Form class that you
created.

Passing a form around is like passing any other object around. It is
nothing more than an object, and should be treated as such, as all the same
rules apply. It has no more or less privledge than any other object (in
terms of how it is used).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ron Rohrssen" <ro**********@yahoo.com> wrote in message
news:0a****************************@phx.gbl...
I want to show a dialog and when the form (dialog) is
closed, return to the calling form. The calling form
should then be able to pass the child form to another
object with the form as a parameter.

For example,

FormOptions formOptions = new FormOptions();
if (formOptions.ShowDialog(this) == DialogResult.OK)
{
ConfigurationManager configurationManager = new
ConfigurationManager();

configurationManager.saveConfiguration(formOptions );
}

formOptions.Dispose();

My ConfigurationManager has a method that looks like
this:
public void saveConfiguration(FormOptions formOptions)
{
ConfigurationData configurationData = new
ConfigurationData
(formOptions);
saveConfiguration(configurationData);
}

When I build this code I keep getting an error like this:
ConfigurationData.cs(20): The type or namespace
name 'FormOptions' could not be found (are you missing a
using directive or an assembly reference?)

These classes are all within the same namespace.

Is it possible to pass the form object to another class?
Or do I need to extract values from the form and pass
them on to my ConfigurationManager?

I've even tried qualifying the FormOptions class in my
parameter list as SCT.FormOptions. "SCT" is my namespace.

Intellisense doesn't see any of my forms when I try to
qualify the FormOptions class.

I suppose this is a pretty simple solution. But, it's
frustrating.

Nov 15 '05 #2
Thanks Nicholas.

But, how do I create a reference to my form from the
class that receives the form as a parameter?

Ron
-----Original Message-----
Ron,

They might all be in the same namespace, but is the form and the classin the same assembly? If not, then you have to make sure that the classthat the form is being passed to has a reference to the Form class that youcreated.

Passing a form around is like passing any other object around. It isnothing more than an object, and should be treated as such, as all the samerules apply. It has no more or less privledge than any other object (interms of how it is used).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ron Rohrssen" <ro**********@yahoo.com> wrote in message
news:0a****************************@phx.gbl...
I want to show a dialog and when the form (dialog) is
closed, return to the calling form. The calling form
should then be able to pass the child form to another
object with the form as a parameter.

For example,

FormOptions formOptions = new FormOptions();
if (formOptions.ShowDialog(this) == DialogResult.OK)
{
ConfigurationManager configurationManager = new
ConfigurationManager();

configurationManager.saveConfiguration(formOptions );
}

formOptions.Dispose();

My ConfigurationManager has a method that looks like
this:
public void saveConfiguration(FormOptions formOptions)
{
ConfigurationData configurationData = new
ConfigurationData
(formOptions);
saveConfiguration(configurationData);
}

When I build this code I keep getting an error like this: ConfigurationData.cs(20): The type or namespace
name 'FormOptions' could not be found (are you missing a using directive or an assembly reference?)

These classes are all within the same namespace.

Is it possible to pass the form object to another class? Or do I need to extract values from the form and pass
them on to my ConfigurationManager?

I've even tried qualifying the FormOptions class in my
parameter list as SCT.FormOptions. "SCT" is my namespace.
Intellisense doesn't see any of my forms when I try to
qualify the FormOptions class.

I suppose this is a pretty simple solution. But, it's
frustrating.

.

Nov 15 '05 #3
Ron,

You don't add references to classes, rather the project that you are in
needs to reference the project that the form is in.

However, are these two in the same project? If they are, then I think
that the namespace declaration is incorrect for one of the elements (the
form or the class trying to use the form).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ron Rohrssen" <ro**********@yahoo.com> wrote in message
news:03****************************@phx.gbl...
Thanks Nicholas.

But, how do I create a reference to my form from the
class that receives the form as a parameter?

Ron
-----Original Message-----
Ron,

They might all be in the same namespace, but is the

form and the class
in the same assembly? If not, then you have to make

sure that the class
that the form is being passed to has a reference to the

Form class that you
created.

Passing a form around is like passing any other

object around. It is
nothing more than an object, and should be treated as

such, as all the same
rules apply. It has no more or less privledge than any

other object (in
terms of how it is used).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ron Rohrssen" <ro**********@yahoo.com> wrote in message
news:0a****************************@phx.gbl...
I want to show a dialog and when the form (dialog) is
closed, return to the calling form. The calling form
should then be able to pass the child form to another
object with the form as a parameter.

For example,

FormOptions formOptions = new FormOptions();
if (formOptions.ShowDialog(this) == DialogResult.OK)
{
ConfigurationManager configurationManager = new
ConfigurationManager();

configurationManager.saveConfiguration(formOptions );
}

formOptions.Dispose();

My ConfigurationManager has a method that looks like
this:
public void saveConfiguration(FormOptions formOptions)
{
ConfigurationData configurationData = new
ConfigurationData
(formOptions);
saveConfiguration(configurationData);
}

When I build this code I keep getting an error like this: ConfigurationData.cs(20): The type or namespace
name 'FormOptions' could not be found (are you missing a using directive or an assembly reference?)

These classes are all within the same namespace.

Is it possible to pass the form object to another class? Or do I need to extract values from the form and pass
them on to my ConfigurationManager?

I've even tried qualifying the FormOptions class in my
parameter list as SCT.FormOptions. "SCT" is my namespace.
Intellisense doesn't see any of my forms when I try to
qualify the FormOptions class.

I suppose this is a pretty simple solution. But, it's
frustrating.

.

Nov 15 '05 #4
Yes! The my form class is in the same project as the
class that I'm trying to pass it to.

I think that's why I'm confused on why I would need to do
anything special to use this feature.

I've verified that all of my classes (only 7 right now)
are in the same namespace. I've copied the "namespace
SCT" line to each of my classes, replacing what was
there. Plus when I use my class browser, all of the
classes appear within the SCT namespace.

Confusing, isn't it?

Thanks for your help.

I hope that you (or anyone else) is able to offer a way
to make this work.
-----Original Message-----
Ron,

You don't add references to classes, rather the project that you are inneeds to reference the project that the form is in.

However, are these two in the same project? If they are, then I thinkthat the namespace declaration is incorrect for one of the elements (theform or the class trying to use the form).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ron Rohrssen" <ro**********@yahoo.com> wrote in message
news:03****************************@phx.gbl...
Thanks Nicholas.

But, how do I create a reference to my form from the
class that receives the form as a parameter?

Ron
>-----Original Message-----
>Ron,
>
> They might all be in the same namespace, but is the
form and the class
>in the same assembly? If not, then you have to make

sure that the class
>that the form is being passed to has a reference to
the Form class that you
>created.
>
> Passing a form around is like passing any other

object around. It is
>nothing more than an object, and should be treated as

such, as all the same
>rules apply. It has no more or less privledge than
any other object (in
>terms of how it is used).
>
> Hope this helps.
>
>
>--
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard.caspershouse.com
>
>"Ron Rohrssen" <ro**********@yahoo.com> wrote in
message >news:0a****************************@phx.gbl...
>> I want to show a dialog and when the form (dialog) is >> closed, return to the calling form. The calling form
>> should then be able to pass the child form to another >> object with the form as a parameter.
>>
>> For example,
>>
>> FormOptions formOptions = new FormOptions();
>> if (formOptions.ShowDialog(this) == DialogResult.OK)
>> {
>> ConfigurationManager configurationManager = new
>> ConfigurationManager();
>>
>> configurationManager.saveConfiguration(formOptions );
>> }
>>
>> formOptions.Dispose();
>>
>> My ConfigurationManager has a method that looks like
>> this:
>>
>>
>> public void saveConfiguration(FormOptions formOptions) >> {
>> ConfigurationData configurationData = new
>> ConfigurationData
>> (formOptions);
>> saveConfiguration(configurationData);
>> }
>>
>> When I build this code I keep getting an error like

this:
>> ConfigurationData.cs(20): The type or namespace
>> name 'FormOptions' could not be found (are you missing a
>> using directive or an assembly reference?)
>>
>> These classes are all within the same namespace.
>>
>> Is it possible to pass the form object to another

class?
>> Or do I need to extract values from the form and

pass >> them on to my ConfigurationManager?
>>
>> I've even tried qualifying the FormOptions class in my >> parameter list as SCT.FormOptions. "SCT" is my

namespace.
>>
>> Intellisense doesn't see any of my forms when I try to >> qualify the FormOptions class.
>>
>> I suppose this is a pretty simple solution. But, it's >> frustrating.
>
>
>.
>

.

Nov 15 '05 #5

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

Similar topics

2
by: Thomas Philips | last post by:
To experiment with filtering, I define a function f(x,k) as follows >>> def f(x,k=2): return x%k==0 I can check that it works by typing >>> f(10,3) False Now, I try to filter a range using...
2
by: muser | last post by:
How can I pass the parameter " long part_num, into a case statement. Case statement follows the function CheckDigit. i.e. CheckDigit( something, temp1 ); Thank you for your help in advance. ...
2
by: Nautilus | last post by:
Taken from a couple very similar samples on the net, I'm having trouble passing a parameter to a PHP file. Here's all the JS code ... it creates an image object and modifies it's src to make a...
10
by: Tracy | last post by:
Dear all, I have encountered a problem in passing a VARCHAR parameter (which is a list of accepted values) to the IN predicate of a DB2 user-defined function. For example, I have a table...
1
by: matthew breedlove | last post by:
I have a Managed VC++ WinForms app in VC8 calling a member function of a class in a native DLL. My managed code is similar to this: System::Void btnTest_Click(System::Object^ sender,...
0
by: dawg1998 | last post by:
I am able to populate a DropDownList control within multiple rows of a GridView with the following code: `````````````````````````````````````````````````````` <asp:GridView id="gvGridView"...
2
by: JackC | last post by:
Hi, I create my threads like this: for(int j = 0; j < 5; j++) { boost::thread *thr = new boost::thread(worker_func); threads.add_thread(thr); }
3
by: fxeko | last post by:
Hi all... I have got a problem about passing data parameter in data report VB6 my problem: x= "admin" how to send value of x variabel to data report Thanks for your advabced
13
by: masso600 | last post by:
char word; in = fopen("test.txt", "r"); while(fscanf(in,"%s",&word)!=EOF) { /* Print all words */ /* printf("%s\n",&word); */
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.