|
-
Jul 14th, 2006, 11:06 PM
#1
Thread Starter
Addicted Member
[02/03] Access controls of other forms
I have Form1(Textbox1, Button1) and Form2(Textbox2).
When I click Button1 of Form1, it will display Form2. In Form2, i want to access the Textbox1(any controls) of Form1. Any solution?
-
Jul 14th, 2006, 11:29 PM
#2
Re: [02/03] Access controls of other forms
"Imagination is more important than knowledge..."
Albert Einstein
-----------------------------------------------
If my reply helped you then you really were lost, but I still took the time to help, please rate it anyway
-
Jul 15th, 2006, 12:55 AM
#3
Re: [02/03] Access controls of other forms
In VB.NET all forms are classes and form instances are just objects. One thing you could do is pass a reference to the first form in the constructor of the second, so when you show it it already has knowledge of the first form.
One key principle to correct object-oriented design is scope - you shouldn't give anything a higher scope than needed.
-
Jul 15th, 2006, 04:31 AM
#4
Re: [02/03] Access controls of other forms
VB Code:
Public Class Form2
Public Sub New(ByRef frm As Form2)
frm.TextBox1.Text="Welcome"
End Sub
End Class
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 15th, 2006, 07:53 PM
#5
Thread Starter
Addicted Member
Re: [02/03] Access controls of other forms
Thanks. Why in VB 2005 we can use FormName.AnyControl without declare an instance of form? Is it shared member or something else?
-
Jul 16th, 2006, 02:07 AM
#6
Re: [02/03] Access controls of other forms
You are referring to My.FormName, which is an instance of the form
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|