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
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;
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.