Search code examples
c#winformstelerikradgridviewgridviewcolumn

Bind GridViewComboBoxColumn Datasource programmatically


On a WinForms application with C# I'm using RadGridView control of Telerik company.

One of the columns of this RadGridView is of type GridViewComboBoxColumn. I want to give this column a DataSource populated at runtime and then set the three important properties of the ComboBox (DataSource, DisplayMember, ValueMember).

How can I programmatically do this?

I've tried

DataGridViewComboBoxColumn comboIBAN = 
    rgvCheques.Columns["clmnIBAN"] as DataGridViewComboBoxColumn;

But it ends up with the following error

Error message


Solution

  • Thanks everyone for they effort and answers, all the answers were about adding a column to the grid, what I was looking for was to point to (retrieve) the current column and change its properties, such as DataSource as the most important one.

    The solution I finally came up with is written below, maybe it helps to other people looking for such answer :

    ((GridViewComboBoxColumn)rgvCheques.Columns["IBAN"]).DataSource = 
        lstBankAccounts.Items;