I have the following code to populate a DataGridViewComboBoxColumn
try
{
itemReader = sc.ExecuteReader();
itemDT = new DataTable();
itemDT.Columns.Add("id", typeof(string));
itemDT.Columns.Add("ar_desc", typeof(string));
itemDT.Load(itemReader);
itemIDcmbColmn.ValueMember = "id";
itemIDcmbColmn.DisplayMember = "ar_desc";
itemIDcmbColmn.DataSource = itemDT;
}
catch (Exception e)
{
MessageBox.Show("Exception - populateGridComboBox(): " + e.Message);
}
finally
it populates the combobox fine. I have a button to insert new record into DataGridViewComboBoxColumn which open another form FormB and prompt the user to enter the name and ID for the new item. But the problem is that the newly added item do not appear in the comboBox until I close and re-open FormA. here is my code in FormB:
BindingSource bs = new BindingSource();
DataGridViewComboBoxColumn itemCmbClmn = prcFrm.itemIDcmbColmn; //Get FormsA DataGridViewComboBoxColumn
DataTable itemDataTable = prcFrm.ItemData; //Get FormA datatable
itemCmbClmn.ValueMember = itemID.ToString();
itemCmbClmn.DisplayMember = txtItemAr.Text;
bs.DataSource = itemDataTable;
itemCmbClmn.DataSource = bs;
prcFrm.dataGridView1.Update();
When I run the addNew I got an exception that Field doesn't exist. Any help please, I am new to C# and visual studio, thank you in advance