0

Hey.

As the topic states i want to use a streamwriter to write the listbox from form1, but the streamwriter is in form2. How do i get the data from form1 to form2?

I have the code to write everything out etc, all I need is help to get the data from form1 to form2, thanks.

3
Contributors
3
Replies
7
Views
7 Years
Discussion Span
Last Post by can-inlife
0

You should make Form2 constructor take a ListBox as a parameter and then pass form1's ListBox as a parameter when initiating Form2.

An example:

When initiating Form2, pass that ListBox as a parameter:

Form2 form2 = new Form2([B]listBox1[/B]);

And edit Form2;s constructor:

// This will hold the listbox from Form1
ListBox listBox1;

public Form2(ListBox L)
{
   InitializeComponent();
   
   // Now this holds form1's listbox
   listBox1 = L;
}

Hope that helps.

Thanks

Edited by farooqaaa: n/a

0

Yep that did it.

Thank you very much for your help!

0

ı have a form like here. ıt have a listbox.
and ı have harita.cs (not a form so)

ı want to write ıtem to listbox which on form1.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.