D
Debra has a question
Guest
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 thats how the columns in the datagridview clear and reload. The problem is that the combobox column doesnt clear so when I reload it it has this column 2 times. I cant do datagridview.columns.clear because its loaded straight from a datatable. How can I fix this problem?
Here is some of the code:
if (dsInvoicingFilter != null) dsInvoicingFilter.Dispose();
dsInvoicingFilter = new DataSet();
if (bs != null) bs.Dispose();
bs = new BindingSource();
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 = new DataGridViewComboBoxColumn();
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
Continue reading...
Here is some of the code:
if (dsInvoicingFilter != null) dsInvoicingFilter.Dispose();
dsInvoicingFilter = new DataSet();
if (bs != null) bs.Dispose();
bs = new BindingSource();
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 = new DataGridViewComboBoxColumn();
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
Continue reading...