-1

I've created a simple winform with one databound datagridview. The user should be able to change values in the grid. One column of this grid is a combobox called comb1. The source of comb1 is a select to database. Everything works very well. But.....

After deleting one entry in the source of the combobox comb1 whitch is already used in the datagridview, the datagridview fails when opening. The combobox tries to validate the value in the datagridviewcolumn comb1. But this is not possible, because one entry of the combobox-source is deleted. Error: The datagridviewcomboboxcell-value is not valid.

Hope, you can understand.... How can I fix this? Thanks.

Ralle
  • 1
  • 1

1 Answers1

0
  SqlDataAdapter sda = new SqlDataAdapter("SELECT T_Artikel.ArtikelBezeichnung, T_Artikel.IDArtikel AS Expr1 FROM T_Benutzer_Artikel INNER JOIN T_Artikel ON T_Benutzer_Artikel.IDArtikel = T_Artikel.IDArtikel WHERE(T_Benutzer_Artikel.IDBenutzer =" + lokIDBenutzer + ")", con);


        DataTable dt = new DataTable();
        sda.Fill(dt);
        iDArtikelDataGridViewComboBoxColumn.DataSource = dt;
        iDArtikelDataGridViewComboBoxColumn.ValueMember = "Expr1";
        iDArtikelDataGridViewComboBoxColumn.DisplayMember = "ArtikelBezeichnung";

This piece of code supplies the source of the combobox when opening the form. After deleting one entry in table T_Artikel the combobox-source is missing this entry und fails when opening the DGV. Hope, this helps.

Ralle
  • 1
  • 1