Get value from other form variable
-
Hi, I'm a beginner, so please help me. I want to know how to get value from other form variable or other form control, from our form. Thanx Regard, Edwin46
-
Hi, I'm a beginner, so please help me. I want to know how to get value from other form variable or other form control, from our form. Thanx Regard, Edwin46
hi, if u have one form as form1 and other as form2 and u want to show data from form1 to form2 then u can pass the values from form1 through the overloaded contructor of the form2.In form1 u could public properties to hold values for passing and then in the constructor pass these prop vals.I hope its clear.
-
Hi, I'm a beginner, so please help me. I want to know how to get value from other form variable or other form control, from our form. Thanx Regard, Edwin46
To get the value of a variable "V" in form "X" from form "Y", expose V as a public property in X, store a reference to an instance of X in Y, and access it. For example:
public class X : Form
{
// The public property
public int V {
get { return v; }
}// Private member variable
int v = 0;
...
}public class Y : Form
{
// Reference to instance of form X
X x;void someMethod()
{
// x must have been properly initialized!
int valueOfVinFormX = x.V;
}
}While this is probably the easiest way, it's not the recommended method of accessing data in other forms. But since you're a beginner, I decided to post a simple and direct answer. /ravi
This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
-
hi, if u have one form as form1 and other as form2 and u want to show data from form1 to form2 then u can pass the values from form1 through the overloaded contructor of the form2.In form1 u could public properties to hold values for passing and then in the constructor pass these prop vals.I hope its clear.
Thanx a lot regard Edwin46
-
To get the value of a variable "V" in form "X" from form "Y", expose V as a public property in X, store a reference to an instance of X in Y, and access it. For example:
public class X : Form
{
// The public property
public int V {
get { return v; }
}// Private member variable
int v = 0;
...
}public class Y : Form
{
// Reference to instance of form X
X x;void someMethod()
{
// x must have been properly initialized!
int valueOfVinFormX = x.V;
}
}While this is probably the easiest way, it's not the recommended method of accessing data in other forms. But since you're a beginner, I decided to post a simple and direct answer. /ravi
This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
Thanx this is very helpfull regard Edwin46
-
Hi, I'm a beginner, so please help me. I want to know how to get value from other form variable or other form control, from our form. Thanx Regard, Edwin46
-
you should try make a public class that returned a control u want to be call in another form:)
Can U give me an example, Please. Thanx a lot regard Edwin46
-
Can U give me an example, Please. Thanx a lot regard Edwin46