|
-
Dec 3rd, 2003, 01:51 PM
#1
Thread Starter
Junior Member
Data from one form to another
I have a main form (form1), I want to open another form and use data from a listBox in form1 in my second form..... how do I make the listbox data visible to the second form? I've tried creating an array variable using "friend" and "shared" but this is not visible to the second form either.
Thanks
-
Dec 3rd, 2003, 02:04 PM
#2
you can add Form2 as an OwnedForm , then you can access Form1's controls / data by casting Form1 as Me.Owner, like this ...
in Form1 ( to show / initialize Form2 )
VB Code:
Dim frm2 As New Form2()
Me.AddOwnedForm(frm2)
frm2.Show()
then in Form2 , to access Form1 ...
VB Code:
Dim frm1 As Form1 = DirectCast(Me.Owner , Form1)
'/// access is now available to Form1's Controls , eg: ...
MessageBox.Show(frm1.TextBox1.Text)
hope it helps.
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Dec 3rd, 2003, 02:16 PM
#3
Sleep mode
Or , Use ShowDialog(this) to show the second form , then make a property that returns array .
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
|