Results 1 to 3 of 3

Thread: Data from one form to another

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Location
    MS
    Posts
    22

    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

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    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:
    1. Dim frm2 As New Form2()
    2. Me.AddOwnedForm(frm2)
    3. frm2.Show()
    then in Form2 , to access Form1 ...
    VB Code:
    1. Dim frm1 As Form1 = DirectCast(Me.Owner , Form1)
    2. '/// access is now available to Form1's Controls , eg: ...
    3. 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]

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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
  •  



Click Here to Expand Forum to Full Width