0

I currently have a form that displays the information of a show and I have a different form that will update the array so the user can add more shows to the collection.

This is the beggining of my form where they can add the data to a listbox

'''

    private void btnAddMovieClear_Click(object sender, EventArgs e)
    {
        txtEnterMovieTitle.Clear();
        txtEnterRuntime.Clear();
        txtEnterYear.Clear();

    }

    private void btnSaveMovie_Click(object sender, EventArgs e)
    {
        lstMovieTitle.Items.Add(txtEnterMovieTitle.Text);
        lstYear.Items.Add(txtEnterYear.Text);
        lstRuntime.Items.Add(txtEnterRuntime.Text);
    }
}

'''

Now I have a different form that simply displays the labels. How would I do it so that I can move the text entered in the listbox to the other form and display it?

Mary
  • 14,926
  • 3
  • 18
  • 27
Eva
  • 1
  • This is C#, so you should edit your question and remove the VB.NET tag. – HardCode Jun 24 '21 at 17:19
  • Does this answer your question? [Communicate between two windows forms in C#](https://stackoverflow.com/questions/1665533/communicate-between-two-windows-forms-in-c-sharp) – JohnG Jun 24 '21 at 17:19
  • 1
    You have three independent ListBox controls, with nothing to associate a Movie Title in that ListBox to the Year or Runtime values in the other ListBoxes. Perhaps you're better off with a data structure (Class, Struct, etc.) to hold a "record" of Title, Year, and Runtime data elements. Then, you're likely better off displaying that data in a DataGridView instead of separate ListBox controls. You can pass your data structure containing the "movie record" to the other form (via Constructor) and display the data in Labels. – HardCode Jun 24 '21 at 17:21
  • I agree with HardCode… I have to ask, is there some reason you have THREE (3) different lists (`lstMovieTitle`,`lstYear` and `lstRuntime`) for ONE(1) movie? This is odd, would it not be easier to create a `Movie` class with those three properties, then have a single list of `Movie` objects? Sorry if I am missing something. – JohnG Jun 24 '21 at 17:24

0 Answers0