There is a DataGridView (c # winforms vs2010 net4.0) to which a line is added (one by one):
private void btn_AddRow_Click(object sender, EventArgs e) { int index = dGV.Rows.Count; index++; dGV.Rows.Add(); int nRowIndex = dGV.Rows.Count - 1; string[] ListGroups = listBox1.Items.OfType<string>().ToArray(); DataGridViewComboBoxCell Col1 = (DataGridViewComboBoxCell)dGV.Rows[nRowIndex].Cells[0]; Col1.DataSource = ListGroups; } The ListGroups list is bound to column1 (Col1), which is formed on the basis of the listBox1 list. In column1, a value is selected. Next, I change (code btn_Groups_Click) the contents of the listBox1 list (for example, delete the value of the string that is selected in column1). As a result, an error occurs.
private void btn_Groups_Click(object sender, EventArgs e) { Form4 frm4 = new Form4(); if (frm4.ShowDialog(this) == DialogResult.OK) { string[] ListGroups = frm4.ListBox2.Items.OfType<string>().ToArray(); listBox1.Items.Clear(); listBox1.Items.AddRange(ListGroups); DataGridViewComboBoxColumn column1 = (DataGridViewComboBoxColumn)dGV.Columns[0]; column1.DataSource = null; column1.DataSource = ListGroups; } frm4.Close(); frm4.Dispose(); } Can you please tell me how, in this case, delete (possibly with a user notification that such a value is already missing) from column 1 there is already a missing value and rebind to the modified listBox1?