Code Q & A
  • index
  • Java
  • python
  • javascript
No Result
View All Result
Code Q & A
  • index
  • Java
  • python
  • javascript
No Result
View All Result
Code Q & A
No Result
View All Result

C# New Row, BindingSource, DataGridView

06/23/2022
in bindingsource, c#, combobox, datagridview, datasource
Reading Time: 1 min read

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.

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

dgvEpisoden.Rows.Clear();
dgvEpisoden.Refresh();
Tags: bindingsourcec#comboboxdatagridviewdatasource
ShareTweetPin

Related Posts

asp.net-core

ASP.NET Core return JSON with status code

I'm looking for the correct way to return JSON with a HTTP status code in my .NET Core Web API...

.net

Exception when connecting to SFTP server using WinSCP C# code - PrivateKeyPassphrase is set, but not SshPrivateKeyPath and TlsClientCertificatePath

I am building an application which uses C# code to connect to an SFP server. The other party says that...

.net

"The handshake failed due to an unexpected packet format" FluentFTP error when connecting to SFTP server

I am trying to connect to SFTP server to download some files. The code is written in C# and I...

.net

Upload file to implicit FTPS server in C# with TLS session reuse

I'm trying to upload file to FileZilla server through ftps by protocol TLS. On the server port 20 and 21...

Next Post

C# combobox set custom DiplayMember

Hot tags

.htaccess .net Algorithm amazon-web-services android Apache c# css c语言 django django-models docker google-app-engine google-cloud-platform hadoop Hive html ios java javascript kubernetes linux macos maven mysql node.js php postgresql python python-2-7 Python 3.X R ruby ruby-on-rails spring SQL SQL SERVER svn TensorFlow ubuntu windows xcode 爬虫 算法 编程语言

    © 2022 Websitedic.com.

    No Result
    View All Result
    • index
    • Java
    • python
    • javascript