473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Getting value from one form to another in Windows Forms

Hi,

I have 3 forms in my application. Form1 which is a MDI form calling Form2 & Form3. Form2 has a textbox "TextBox1" and Form3 has a CommandButton "Button1".

I will show both Form1 & Form2 as MDI Child from Form1. Now when i click on the Button1 in Form3, I want to access the TextBox1 value of Form2.

How to achieve this... in VB6 is was very simple as I can use Form2.TextBox1 but how in VB.Net or C#

Thanks...

Pradeep
Nov 20 '05 #1
6 1786
Hi Pradeel,

Have a look at the me.parentform from your form.

http://msdn.microsoft.com/library/de...tformtopic.asp

When you have that, you can again get the childforms of that form.

I hope this help?

Cor

Hi,

I have 3 forms in my application. Form1 which is a MDI form calling Form2 & Form3. Form2 has a textbox "TextBox1" and Form3 has a CommandButton
"Button1".
I will show both Form1 & Form2 as MDI Child from Form1. Now when i click on the Button1 in Form3, I want to access the TextBox1 value of Form2.
How to achieve this... in VB6 is was very simple as I can use Form2.TextBox1 but how in VB.Net or C#
Thanks...

Pradeep

Nov 20 '05 #2
Hi,

In this case my MDI form is not doing anything other than just calling the Form2 & Form3.

I need to get the data of Form2 from Form3 where both are MDI Childs.

Thanks

Pradeep

"Cor Ligthert" wrote:
Hi Pradeel,

Have a look at the me.parentform from your form.

http://msdn.microsoft.com/library/de...tformtopic.asp

When you have that, you can again get the childforms of that form.

I hope this help?

Cor

Hi,

I have 3 forms in my application. Form1 which is a MDI form calling Form2

& Form3. Form2 has a textbox "TextBox1" and Form3 has a CommandButton
"Button1".

I will show both Form1 & Form2 as MDI Child from Form1. Now when i click

on the Button1 in Form3, I want to access the TextBox1 value of Form2.

How to achieve this... in VB6 is was very simple as I can use

Form2.TextBox1 but how in VB.Net or C#

Thanks...

Pradeep


Nov 20 '05 #3
Did you try it?

In this case my MDI form is not doing anything other than just calling the Form2 & Form3.
I need to get the data of Form2 from Form3 where both are MDI Childs.

Thanks

Pradeep

"Cor Ligthert" wrote:
Hi Pradeel,

Have a look at the me.parentform from your form.

http://msdn.microsoft.com/library/de...tformtopic.asp
When you have that, you can again get the childforms of that form.

I hope this help?

Cor

Hi,

I have 3 forms in my application. Form1 which is a MDI form calling
Form2 & Form3. Form2 has a textbox "TextBox1" and Form3 has a CommandButton
"Button1".

I will show both Form1 & Form2 as MDI Child from Form1. Now when i
click on the Button1 in Form3, I want to access the TextBox1 value of Form2.

How to achieve this... in VB6 is was very simple as I can use

Form2.TextBox1 but how in VB.Net or C#

Thanks...

Pradeep


Nov 20 '05 #4
That is not my requirement...

"Cor Ligthert" wrote:
Did you try it?

In this case my MDI form is not doing anything other than just calling the

Form2 & Form3.

I need to get the data of Form2 from Form3 where both are MDI Childs.

Thanks

Pradeep

"Cor Ligthert" wrote:
Hi Pradeel,

Have a look at the me.parentform from your form.

http://msdn.microsoft.com/library/de...tformtopic.asp
When you have that, you can again get the childforms of that form.

I hope this help?

Cor

Hi,
>
> I have 3 forms in my application. Form1 which is a MDI form calling Form2 & Form3. Form2 has a textbox "TextBox1" and Form3 has a CommandButton
"Button1".
>
> I will show both Form1 & Form2 as MDI Child from Form1. Now when i click on the Button1 in Form3, I want to access the TextBox1 value of Form2.
>
> How to achieve this... in VB6 is was very simple as I can use
Form2.TextBox1 but how in VB.Net or C#
>
> Thanks...
>
> Pradeep


Nov 20 '05 #5
Hi PradeepKel,

As I asked before did you try it, by instance this in form3?
\\\\
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
For Each frm As Form In _
Me.ParentForm.MdiChildren()
If frm.Name = "Form2" Then
TextBox1.Text = DirectCast(frm, Form2).TextBox1.Text
End If
Next
End Sub
///

I hope this fullfils your needs, I tested it and it did go.
(You can of course as well create a shared property to use, however this is
a direct anwer in my opinion on your question)

Cor
"
That is not my requirement...

"Cor Ligthert" wrote:
Did you try it?

In this case my MDI form is not doing anything other than just calling the
Form2 & Form3.

I need to get the data of Form2 from Form3 where both are MDI Childs.

Thanks

Pradeep

"Cor Ligthert" wrote:

> Hi Pradeel,
>
> Have a look at the me.parentform from your form.
>
>

http://msdn.microsoft.com/library/de...tformtopic.asp >
> When you have that, you can again get the childforms of that form.
>
> I hope this help?
>
> Cor
>
> Hi,
> >
> > I have 3 forms in my application. Form1 which is a MDI form calling Form2
> & Form3. Form2 has a textbox "TextBox1" and Form3 has a

CommandButton > "Button1".
> >
> > I will show both Form1 & Form2 as MDI Child from Form1. Now when i

click
> on the Button1 in Form3, I want to access the TextBox1 value of Form2. > >
> > How to achieve this... in VB6 is was very simple as I can use
> Form2.TextBox1 but how in VB.Net or C#
> >
> > Thanks...
> >
> > Pradeep
>
>
>


Nov 20 '05 #6
Hi cor,

Thanks a lot... it works fine...

Just to know... how to handle the situation if the MDI form is not available.

Regards

Pradeep

"Cor Ligthert" wrote:
Hi PradeepKel,

As I asked before did you try it, by instance this in form3?
\\\\
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
For Each frm As Form In _
Me.ParentForm.MdiChildren()
If frm.Name = "Form2" Then
TextBox1.Text = DirectCast(frm, Form2).TextBox1.Text
End If
Next
End Sub
///

I hope this fullfils your needs, I tested it and it did go.
(You can of course as well create a shared property to use, however this is
a direct anwer in my opinion on your question)

Cor
"
That is not my requirement...

"Cor Ligthert" wrote:
Did you try it?
>
> In this case my MDI form is not doing anything other than just calling the Form2 & Form3.
>
> I need to get the data of Form2 from Form3 where both are MDI Childs.
>
> Thanks
>
> Pradeep
>
> "Cor Ligthert" wrote:
>
> > Hi Pradeel,
> >
> > Have a look at the me.parentform from your form.
> >
> >
http://msdn.microsoft.com/library/de...tformtopic.asp > >
> > When you have that, you can again get the childforms of that form.
> >
> > I hope this help?
> >
> > Cor
> >
> > Hi,
> > >
> > > I have 3 forms in my application. Form1 which is a MDI form calling Form2
> > & Form3. Form2 has a textbox "TextBox1" and Form3 has a CommandButton > > "Button1".
> > >
> > > I will show both Form1 & Form2 as MDI Child from Form1. Now when i
click
> > on the Button1 in Form3, I want to access the TextBox1 value of Form2. > > >
> > > How to achieve this... in VB6 is was very simple as I can use
> > Form2.TextBox1 but how in VB.Net or C#
> > >
> > > Thanks...
> > >
> > > Pradeep
> >
> >
> >


Nov 20 '05 #7

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

Similar topics

1
by: orit | last post by:
I have the following xml file: <?xml version="1.0" encoding="utf-8" ?> <course id="2555" title="Developing Microsoft .NET Applications for Windows (Visual C# .NET)" length="5 days"...
2
by: Jeff Van Epps | last post by:
We've been unable to get events working going from C# to VJ++. We think that the C# component is being exposed properly as a ConnectionPoint, and the Advise() from the VJ++ side seems to be...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
7
by: Microsoft | last post by:
I'm not sure where to physically place my subroutines in vb.net I get namespace and not declared errors... Imports System Imports System.Management Public Class Form1
5
by: Erol | last post by:
How do I get a type from a string? I'm retrieving a string value from my database so that I can set my property values dynamically. In the event "Form1_Load", you will see that I'm trying to set...
1
by: Flack | last post by:
Hey guys, Here is whats happening. I have a StringBuilder, a TextBox, and a TabControl with one TabPage. On my main form, I created and displayed a fairly big maze. While the app is solving...
19
by: Dave | last post by:
If Iwant to check if dataset1.SelectQuery1.column1 == System.DBNull.Value. How do I do this? What I wrote above will give an error. -- L. A. Jones
8
by: =?Utf-8?B?QW1yaXQgS29obGk=?= | last post by:
Okay, after much research, I have discovered a few interesting things in ASP.NET. I have a MasterPage that has a WebForm on it and it looks like this: <body> <form id="controls"...
7
by: pooba53 | last post by:
I am working with VB .NET 2003. Let's say my main form is called Form1. I have to launch a new form (Form2) that gathers input from the user. How can I pass variable information back to Form1...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.