Results 1 to 3 of 3

Thread: Passing ArrayList

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    5

    Post Passing ArrayList

    I have to forms and an arraylist
    when i want to access to arraylist from another form
    I cant access arraylist's items .
    I define all of them public .
    source code is here
    Attached Files Attached Files

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    You need to have a reference to the form 1 that is already created. You are making a new form1 object, but that isn't the same form1 that opened form2.

    In Form2 constructor add in a argument that you can pass in a current reference the form that is creating this form
    Code:
    private Form1 fm1;
    
    
    public Form2(Form1 myFrm)
    {
    	InitializeComponent();
                    fm1 = myFrm;
    }
    Now, in form1, when you create a form2 object, you pass in a reference of itself:
    Code:
    Form2 fm2 = new Form2(this) ;

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    5
    Thank you very much

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