Thank you all for your interest in helping. Yes, I have a Form, that
defines a private field which is a TextBox that contains a value.
say:
private System.Windows.Forms.TextBox EFW;
During the processing of this form, a new form can be
launched, and in the new form, I would like to capture the
value that was entered in the first form TextBox.
Since the 2 forms (classes) are within the same namespace,
I just though to define a variable of type Form1 inside the second form.
i.e.
private MyNameSpace.Form1 cForm1;
This will be pointing to null if I do not instantiate, but if I do
instantiate, a new object is created in the heap, which is not referencing
the initial Form1. The question is what is the best way to declare the
variable in the first form, and how to do it in the second form, so that it
can access
the variable that has a value in it.
I kind of solved it by declaring a
static public int sVar;
in the first form, so that will hold such value, and I will access it
in the second form without instatiating a new object. Since I am
just getting the skills in C#, I just wanted to know if there is a more
elegant way to do it using object programming theory.
Thanks in advance..
static public int spiEFW;
<al*******@users.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
There seems to be a mix up between class and object
The class Form1 exists within the Namespace MyNameSpace
Objects exist within a scope and are access with reference to that
scope.
Where are you placing the
private MyNameSpace.Form1 cForm1;
declaration?
That is what defines how it can be accessed.
By making it Private you are limiting access to it, saying that only
items in the same declaration context / scope (or those nested within
it) can access it.
If you declared it inside a class, only members of that class can see
it
If you declared it in a module, only methods within that module can
see it.
Can you give some code snippets showing the classes/modules involved
and where you are declaring / trying to access the object?
Alan.