This is a migrated thread and some comments may be shown as answers.

two combobox

1 Answer 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Вадим
Top achievements
Rank 1
Iron
Iron
Вадим asked on 27 Aug 2017, 09:37 AM

Separately, the comboBoxs work fine, but they do not want to do it together, but at the time of loading it gives an error: an entry with this key already exists on the radGridView5.Columns [3] = comboColumn_operation ;.
Downloading occurs once

radGridView5.Invoke(new MethodInvoker(delegate ()             {                 radGridView5.AutoSizeRows = true;                 radGridView5.DataSource = _bindingSocOperationGrid;                   GridViewComboBoxColumn comboColumn = new GridViewComboBoxColumn("соц. работник");                 comboColumn.DataSource = _bindingSocRabotnik;                 radGridView5.Columns[1] = comboColumn;                 comboColumn.FieldName = "fio";                   GridViewComboBoxColumn comboColumn_operation = new GridViewComboBoxColumn("операция");                 comboColumn_operation.DataSource = _bindingSocOperation;                 radGridView5.Columns[3] = comboColumn_operation;                 comboColumn_operation.FieldName = "operation";             }));

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Aug 2017, 09:49 AM
Hello Вадим, 

Thank you for writing.  

When you replace some of the columns, make sure that you don't have already a column with the same name. Here is a sample code snippet which result is illustrated in the attached gif file:
private void radButton1_Click(object sender, EventArgs e)
{
    radGridView1.AutoSizeRows = true;
    radGridView1.DataSource = this.productsBindingSource;
    GridViewComboBoxColumn comboColumn = new GridViewComboBoxColumn("Categories");
    comboColumn.DataSource = this.categoriesBindingSource;
    comboColumn.DisplayMember = "CategoryName";
    comboColumn.ValueMember = "CategoryID";
    comboColumn.Name = "CategoryID";
    if (this.radGridView1.Columns.Contains("CategoryID"))
    {
        this.radGridView1.Columns.Remove("CategoryID");
    }
    radGridView1.Columns[2] = comboColumn;
    comboColumn.FieldName = "CategoryID";
    GridViewComboBoxColumn comboColumn_operation = new GridViewComboBoxColumn("Suppliers");
    comboColumn_operation.DataSource = this.suppliersBindingSource;
    comboColumn_operation.DisplayMember = "ContactName";
    comboColumn_operation.ValueMember = "SupplierID";
    comboColumn_operation.Name = "SupplierID";
    if (this.radGridView1.Columns.Contains("SupplierID"))
    {
        this.radGridView1.Columns.Remove("SupplierID");
    }
    radGridView1.Columns[3] = comboColumn_operation;
    comboColumn_operation.FieldName = "SupplierID";
}
 
private void RadForm1_Load(object sender, EventArgs e)
{
    // TODO: This line of code loads data into the 'nwindDataSet.Suppliers' table. You can move, or remove it, as needed.
    this.suppliersTableAdapter.Fill(this.nwindDataSet.Suppliers);
    // TODO: This line of code loads data into the 'nwindDataSet.Products' table. You can move, or remove it, as needed.
    this.productsTableAdapter.Fill(this.nwindDataSet.Products);
    // TODO: This line of code loads data into the 'nwindDataSet.Categories' table. You can move, or remove it, as needed.
    this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories);
}

If you are still experiencing any further difficulties, feel free to submit a support ticket from your account. Thus, Telerik support will gladly assist you.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Вадим
Top achievements
Rank 1
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or