2

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

Mahdi Tahsildari
  • 13,065
  • 14
  • 55
  • 94

3 Answers3

5

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;
Mahdi Tahsildari
  • 13,065
  • 14
  • 55
  • 94
0

GridViewComboBoxColumn displays a set of predefined candidate text values in a drop down list. This column type is typically used to provide a lookup into some set of relatively static values.

To use GridViewComboBoxColumn Check this one

andy
  • 5,979
  • 2
  • 27
  • 49
0

Check this out

GridViewComboBoxColumn CustomColumn= new GridViewComboBoxColumn();
CustomColumn.Name = "CustomColumn";
CustomColumn.HeaderText = "MyHeader";
CustomColumn.DataSource = this.MyBindingSource;
CustomColumn.ValueMember = "CustomID";
CustomColumn.DisplayMember = "CustomName";
CustomColumn.FieldName = "CustomID";
CustomColumn.Width = 200;
this.radGridView1.Columns.Add(CustomColumn);

Hope this helps

Rohit
  • 10,056
  • 7
  • 50
  • 82
  • Kyle I don't want to add the column, I already have it. I want to fill it with a datasource. -1 deserved but not performed :) And for the object names use the right casing `customColumn` means an object nad `CustomColumn` means a Class. – Mahdi Tahsildari Jan 23 '13 at 08:55