473,387 Members | 1,485 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,387 software developers and data experts.

multiple-Form Application.

I need to synchronize the contents of 2 textboxes that are on
different forms.
When I change the contents of the textbox on Form1, the contents of
the textbox on Form2 should be changed to show the same contents as
that of the textbox on Form1, and vice-versa.

Form1 is the startup form for the application, in which I add:

Dim frm2 as new Form2

then in Form1_Load event:

frm2.Show().

in Form1 textbox1_textchanged event:

frm2.Textbox1.Text = Textbox1.Text.

That is all fine.

Then Textbox1_TextChanged event in frm2 I add:

form1.textbox1.text = textbox1.text.

This last line of code is my problem. It seems to me that Form1, the
started form, instantiated by VB on startup, is not available to my
frm2.

I really there must be a simple explanation, but as I am new to
vb.net, it's done me.

Help appreciated.
Nov 21 '05 #1
4 997
Japster,

There are more roads which goes to Rome, however here a sample I did made
now for it.

\\\Form1 has one label
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm As New Form2
frm.Owner = Me
frm.Show()
End Sub
///
\\\form2 has one textbox
Private Sub TextBox1_TextChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles TextBox1.TextChanged
If Not Me.Owner Is Nothing Then
DirectCast(Me.Owner, Form1).Label1.Text = TextBox1.Text
End If
End Sub
////
I hope this helps?

Cor
Nov 21 '05 #2
thanks

my problem has been solved

lal

"Cor Ligthert" <no************@planet.nl> wrote in message
news:ue**************@TK2MSFTNGP12.phx.gbl...
Japster,

There are more roads which goes to Rome, however here a sample I did made
now for it.

\\\Form1 has one label
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm As New Form2
frm.Owner = Me
frm.Show()
End Sub
///
\\\form2 has one textbox
Private Sub TextBox1_TextChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles TextBox1.TextChanged
If Not Me.Owner Is Nothing Then
DirectCast(Me.Owner, Form1).Label1.Text = TextBox1.Text
End If
End Sub
////
I hope this helps?

Cor

Nov 21 '05 #3
Thanks form the reply.

I tried this and it sorted out part of my problem. When text was
changed in form2, form1 was updated. But, unfortunately, when form1
was changed, form2 was not updated.

I am currently studying from a book called SAMS Teach Yourself Visual
Basic.net 2003 in 21 Days. This problem is an exercise in day four.
Prior to this exercise being set, there was a brief mention of a Forms
Collection. Although, since looking at VB.Net Documentation, it
appears that this collection is no longer supported. They can't both
be true!

VB.Net documentation recommends implementing your our own Forms
Collection. This seems to be a long winded way of solving what should
be a simple common problem.
Any more input would be appreciated.

Thanks.

Nov 21 '05 #4
Whooping,

One of the wong things when you use OOP is making classes dependable from
each other.
(When they don't inherit from each other).

And in performance.
People make long messages in this newsgroups about boxing.

Painting in two forms at almost the same time cost definitly much more, so
try to avoid that.

Just my thought,

Cor
Nov 21 '05 #5

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

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
6
by: x. zhang | last post by:
Hi Guys, We know that we can use <input type=file ...> to upload one file per time to the server. My question is if there are some way to upload multiple files per time to the server. (Of...
11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
5
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
5
by: | last post by:
Hi all, HttpWebRequest, and SoapHttpClientProtocol both expose a ClientCertificates property, which can hold multiple client certificates, but on the service side, it can only receive one client...
47
by: Mark | last post by:
why doesn't .NET support multiple inheritance? I think it's so silly! Cheers, Mark
4
by: Matt Kruse | last post by:
While developing an internal IE6-only webapp, a discussion started about the 'best' way to apply classes to data tables across multiple pages. The two arguments were: 1. Apply a single class to...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...

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.