473,490 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Passing data from one form to another when both forms are loaded

How can I pass data from one child form to another? I have two forms, one
(formX) that holds a datagrid (with the results of a query) and another
(formY) that consists of many textboxes. I'd like to pass, for example, a
row from formX to the textboxes of FormY. In this case, since both child
forms are already loaded (both forms are loaded when the MDI loads), I don't
know how to reference formY from within formX.

Is that possible?
Thanks.
Nov 16 '05 #1
2 2144
Hi Jim,

Based on my understainding, you want to find a way to pass data from one
child form to another child form in MDI application.

To pass data to another form, you should have a reference of that form. For
your applicaiton, I think you should create a public property for parent
form, which stores all the child forms' reference. Then each child form can
refer other child form through the public property.

I write a sample like this:

In ParentForm:

public ArrayList FormList=null;
private void ParentForm_Load(object sender, System.EventArgs e)
{
FormList=new ArrayList();
FormX fx=new FormX();
fx.MdiParent=this;
fx.Show();
FormList.Add(fx);

FormY fy=new FormY();
fy.MdiParent =this;
fy.Show();
FormList.Add(fy);
}

For FormY, because its TextBox is a private variable, you should expose it
through property or method, like this:

public void SetText(string str)
{
this.textBox1.Text =str;
}

Then, in FormX, you can pass data like this:

private void button1_Click(object sender, System.EventArgs e)
{
ParentForm pf=(ParentForm)this.MdiParent;
foreach(object obj in pf.FormList)
{
Form f=(Form)obj;
if(f.Name.Equals("FormY"))
{
FormY fy=f as FormY;
fy.SetText("good");
}
}
}

===================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #2
Hi Jim,

Have you tried my suggestion? Do you still have any concern?

Please feel free to let me know, I will help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7159
by: Ryann | last post by:
Hello. I am creating a form that has 5 steps/pages. Each page contains about 20 fields. But I don't want to write them until they submit on the last page. I figured out that I can use hidden...
2
2506
by: Richard | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** HI, I am working on a project where I need to input data to a (local) HTML page using multiple form elements, such as text,...
1
359
by: Jim Heimer | last post by:
How can I pass data from one child form to another? I have two forms, one (formX) that holds a datagrid (with the results of a query) and another (formY) that consists of many textboxes. I'd like...
11
3457
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
8
4393
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
6
3240
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
7
8176
by: The Doctor | last post by:
A rather elementary question, In VB5, how can I pass a variable from one form to another?
0
1533
by: Magnus Bergh | last post by:
I am developing an application for pocketpc and this involvs a but of juggling with different forms. I have an "order entry" type of application. On the main form I have a grid which displays...
4
2333
imrosie
by: imrosie | last post by:
Hello All, (newbie)...I'm working on an Ordering app using the typical tables (customers, orders). I have a Search form to find existing customers prior to entering a new order. On the search form...
6
2398
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The...
0
6974
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...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7183
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...
1
6852
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...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
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 ...

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.