473,761 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Sh owDialog(this) == DialogResult.OK )
{
ConfigurationMa nager configurationMa nager = new
ConfigurationMa nager();

configurationMa nager.saveConfi guration(formOp tions);
}

formOptions.Dis pose();

My ConfigurationMa nager has a method that looks like
this:
public void saveConfigurati on(FormOptions formOptions)
{
ConfigurationDa ta configurationDa ta = new
ConfigurationDa ta
(formOptions);
saveConfigurati on(configuratio nData);
}

When I build this code I keep getting an error like this:
ConfigurationDa ta.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 ConfigurationMa nager?

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 4870
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.co m

"Ron Rohrssen" <ro**********@y ahoo.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.Sh owDialog(this) == DialogResult.OK )
{
ConfigurationMa nager configurationMa nager = new
ConfigurationMa nager();

configurationMa nager.saveConfi guration(formOp tions);
}

formOptions.Dis pose();

My ConfigurationMa nager has a method that looks like
this:
public void saveConfigurati on(FormOptions formOptions)
{
ConfigurationDa ta configurationDa ta = new
ConfigurationDa ta
(formOptions);
saveConfigurati on(configuratio nData);
}

When I build this code I keep getting an error like this:
ConfigurationDa ta.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 ConfigurationMa nager?

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.co m

"Ron Rohrssen" <ro**********@y ahoo.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.Sh owDialog(this) == DialogResult.OK )
{
ConfigurationMa nager configurationMa nager = new
ConfigurationMa nager();

configurationMa nager.saveConfi guration(formOp tions);
}

formOptions.Dis pose();

My ConfigurationMa nager has a method that looks like
this:
public void saveConfigurati on(FormOptions formOptions)
{
ConfigurationDa ta configurationDa ta = new
ConfigurationDa ta
(formOptions);
saveConfigurati on(configuratio nData);
}

When I build this code I keep getting an error like this: ConfigurationDa ta.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 ConfigurationMa nager?

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.co m

"Ron Rohrssen" <ro**********@y ahoo.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.co m

"Ron Rohrssen" <ro**********@y ahoo.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.Sh owDialog(this) == DialogResult.OK )
{
ConfigurationMa nager configurationMa nager = new
ConfigurationMa nager();

configurationMa nager.saveConfi guration(formOp tions);
}

formOptions.Dis pose();

My ConfigurationMa nager has a method that looks like
this:
public void saveConfigurati on(FormOptions formOptions)
{
ConfigurationDa ta configurationDa ta = new
ConfigurationDa ta
(formOptions);
saveConfigurati on(configuratio nData);
}

When I build this code I keep getting an error like this: ConfigurationDa ta.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 ConfigurationMa nager?

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.co m

"Ron Rohrssen" <ro**********@y ahoo.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.co m
>
>"Ron Rohrssen" <ro**********@y ahoo.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.Sh owDialog(this) == DialogResult.OK )
>> {
>> ConfigurationMa nager configurationMa nager = new
>> ConfigurationMa nager();
>>
>> configurationMa nager.saveConfi guration(formOp tions);
>> }
>>
>> formOptions.Dis pose();
>>
>> My ConfigurationMa nager has a method that looks like
>> this:
>>
>>
>> public void saveConfigurati on(FormOptions formOptions) >> {
>> ConfigurationDa ta configurationDa ta = new
>> ConfigurationDa ta
>> (formOptions);
>> saveConfigurati on(configuratio nData);
>> }
>>
>> When I build this code I keep getting an error like

this:
>> ConfigurationDa ta.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 ConfigurationMa nager?
>>
>> 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
4356
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 >>> filter(f(k=3),range(20))
2
2004
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. bool CheckDigit(long part_num, char* record) {
2
1545
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 'call' to the PHP file: var myobj = new Image(); myobj.src = 'http://www.mypage.com/my.php?url=' + 'anything_here'; The process seems to recognize that the file URL ends at the "?", and system logs show that the GET of the PHP file was...
10
3284
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 (mytable) storing ppl names & their corresponding groups. I would like to create a UDF (myfunc) that select a list of ppl names from (mytable) who belong to some dynamic choices of groups. I have tried the following codings but it doesn't work if I
1
1831
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, System::EventArgs^ e) { Receiver r; std::vector<char> v; v.push_back('A');
0
2138
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" runat="server" AutoGenerateColumns="False" DataKeyNames="idRecordID"> <Columns> <asp:TemplateField> <ItemTemplate>
2
3736
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
5443
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
2723
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
9522
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9948
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8770
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.