Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,456 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,920 people online right now. Registration is fast and FREE... Join Now!




How to load data from one form to another form

 
Reply to this topicStart new topic

How to load data from one form to another form

sreenu_pigili
3 Aug, 2008 - 08:50 PM
Post #1

New D.I.C Head
*

Joined: 3 Aug, 2008
Posts: 1

I have two forms i.e form1 and form2.
In form1, i have some one variable called as "layer"
string[] layer=new string[10];
Here, I stored some 5 strings into this string array.
Now i want use these values into form2.
For this i wrote the following code in form2_load()

form1 form1obj=new form1;
form_Load()
{
for(int i=0;i<=10;i++)
{
combobox1.items.add(form1obj.Layer[i]);
}
}

But it is not showing the value of that array "Layer in form1"
So, please correct it.
Thank you.

This post has been edited by sreenu_pigili: 3 Aug, 2008 - 08:50 PM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: How To Load Data From One Form To Another Form
3 Aug, 2008 - 08:56 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,210



Thanked: 214 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Variables which are defined on a form (as well as its controls) are private members of the form. You will have to make them public if you wish to share them. So declare your array as public and then you will be able to access it through the instance of a Form1 variable. smile.gif
User is online!Profile CardPM
+Quote Post

gbertoli3
RE: How To Load Data From One Form To Another Form
3 Aug, 2008 - 09:09 PM
Post #3

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
Martyr2 is right if you don't declare it as public then it is automatically private.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:32PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month