0
votes

i have thress classes 1. class

    public class Episode
{
    public int Folge { get; set; }
    public string Name { get; set; }
    public string Vorhanden { get; set; }
    public Episode(int Folge, string Name, string Vorhanden)
    {
        this.Folge = Folge;
        this.Name = Name;
        this.Vorhanden = Vorhanden;
    }
}

2. class

public class Staffeln
{
    public int Staffel { get; set; }
    public List<Episode> Episoden { get; set; }
    public Staffeln(int Staffel)
    {
        this.Staffel = Staffel;
    }
}

3. class

public class Serien
{
    public string Name { get; set; }
    public List<Staffeln> Staffeln { get; set; }
    public Serien(string Name)
    {
        this.Name = Name;
    }
}

Then i have a Form with a combobox and a DataGridView. The Combobox settings are: DataSource: StaffelnBindingSource DisplayMember: Staffel ValueMember: Staffel

and DataGridview Settings are: DataSource: episodenBindingSource

Staffel in english is Season and Episoden are Episodes. Its a List for me. When i select season 9 in the combobox, then show the dgv the episodes.

Now, i want add more Episodes to the Season, but i dont know how. i try to add the Episodes to the list and set the bindingsource to the list again:

staffelnBindingSource.DataSource = Serien[SerienZahl].Staffeln;

i have also tried

dgvEpisoden.DataSource = episodenBindingSource;

but it dont works. sorry for my english.

1
Use a BindingList instead of a List. Make sure your lists are properly initialized. - LarsTech

1 Answers

0
votes

Possibly try clearing/refreshing the datagrid when you need to change the binding source.

dgvEpisoden.Rows.Clear();
dgvEpisoden.Refresh();