I have a datagridview which gets loaded from a datatable. I also added manually a combobox columns. When I clear the datagridview and reload I dispose the datatable and make a fresh copy of it and that's how the columns in the datagridview clear and reload. The problem is that the combobox column doesn't clear so when I reload it it has this column 2 times. I can't do datagridview.columns.clear because it's loaded straight from a datatable. How can I fix this problem?
Here is some of the code:
if (dsInvoicingFilter !=null) dsInvoicingFilter.Dispose();
dsInvoicingFilter =newDataSet();
if (bs != null) bs.Dispose();
bs =newBindingSource();
switch (invoiceType)
{
case"work orders":
dsInvoicingFilter =Data.GetDataSet("WorkOrders_Select");
DataGridViewBinding.BindWithData(true, dsInvoicingFilter.Tables[0], dgvInvoices, lblEntryCount, bs);
DataTable dt = Data.GetDataTable("Employees_Select");
DataGridViewComboBoxColumn cmbColumn = newDataGridViewComboBoxColumn();
cmbColumn.Name ="PickedBy";
cmbColumn.HeaderText ="Picked By";
cmbColumn.FlatStyle =FlatStyle.Flat;
cmbColumn.DataSource = dt;
cmbColumn.DataPropertyName ="EmployeeID";
cmbColumn.ValueMember ="EmployeeID";
cmbColumn.DisplayMember ="Name";
dgvInvoices.Columns.Add(cmbColumn);
dgvInvoices.Columns[0].SortMode =DataGridViewColumnSortMode.Automatic;
break;
Debra has a question