I am a student and therefore not to bright ;-)
I am currently working on an assignment in C# which requires me to create a program in a windows application using more then one form which I have never done before, infact I have 5 forms and I just cannot seem to figure out how to move information from a variable between them.
I have created a class in which which I have declared all the variables I will need but I cant get to the information from my forms.
Any help would be greatly appriciated.
How can I transfer variables between forms?
Started by katspn, Apr 14 2010 12:19 AM
6 replies to this topic
#1
Posted 14 April 2010 - 12:19 AM
|
|
|
#2
Posted 14 April 2010 - 03:19 AM
I'm not too clear on what you're after. Do you want the 'information' (as in, the values) of components on your form (like the text from a text box)? Or are you literally trying to provide access of declared variables in one form class, to another form class?
Or something entirely different again?
Or something entirely different again?
#3
Posted 14 April 2010 - 05:54 PM
Have a look at this video tutorial. This might help you a bit...
How to Transfer Information Between Forms
How to Transfer Information Between Forms
#4
Posted 15 April 2010 - 10:57 PM
Thanks you for your help,
I have found what the problem was, I did not make the variables "public static".
:cursing:
I have found what the problem was, I did not make the variables "public static".
:cursing:
#5
Posted 16 April 2010 - 02:10 AM
inside a function? Doesn't sound like legal syntax.
#6
Posted 18 May 2010 - 09:25 AM
I was in these situation,and that worked me well.
To transfer data(s) beetwen forms :
Create example a string
:
public static string test = "";
then
test=textbox1.text; //or whatever you want.
Form2 form_that_we_want_to_send_data = new Form2();
//In the main part of form_that_we_want_to_send_data
label1.text=Form1.test;
To transfer data(s) beetwen forms :
Create example a string
:
public static string test = "";
then
test=textbox1.text; //or whatever you want.
Form2 form_that_we_want_to_send_data = new Form2();
//In the main part of form_that_we_want_to_send_data
label1.text=Form1.test;
#7
Posted 22 May 2010 - 12:56 PM
Hi,
//In Form2 (that_we_want_to_Received_data):
Public int MyVariable;
//In Form1 (that we_want_to_send_data):
Form2 frm = new Form2()
frm.MyVariable = Convert.ToInt32(TextBox1.Text);
frm.Show();
Good Luck
//In Form2 (that_we_want_to_Received_data):
Public int MyVariable;
//In Form1 (that we_want_to_send_data):
Form2 frm = new Form2()
frm.MyVariable = Convert.ToInt32(TextBox1.Text);
frm.Show();
Good Luck


Sign In
Create Account

Back to top









