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

GridViewComboBoxColumn - showing an initial value

1 Answer 169 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 29 Oct 2012, 11:06 PM
The documentation states:

If you want to set initial values, you should match the GridViewComboBoxColumn to a column which has appropriate values in it. To do this, you should set the FieldName of the GridViewComboBoxColumn to be the same as the name of the existing column.

Can I see a code sample of how this is done?

I have a text column that I am able to successfully bind to show the values, but I'm not able to replace that text column with a ComboBoxColumn and still have it set the initial values like the text column does. Here's a code sample of what I've tried:

uxgrdBindingsGrid.MasterTemplate.Columns.Clear();
uxgrdBindingsGrid.AutoGenerateColumns = false;
uxgrdBindingsGrid.DataSource = bindings.ToList<SymbolBinding>();
 
 // this textbox column displays fine
GridViewTextBoxColumn dataSourceTextColumn = new GridViewTextBoxColumn();
dataSourceTextColumn.Name = "dataSourceTextColumn";
dataSourceTextColumn.HeaderText = "Data Source";
dataSourceTextColumn.FieldName = "DataSourceProperty";
dataSourceTextColumn.TextAlignment = ContentAlignment.MiddleLeft;
dataSourceTextColumn.Width = 150;
dataSourceTextColumn.IsVisible = true;
uxgrdBindingsGrid.MasterTemplate.Columns.Add(dataSourceTextColumn);
 
// this combobox column displays the drop down list if double-clicked, but does not display any values initially
GridViewComboBoxColumn dataSourceComboColumn = new GridViewComboBoxColumn("DataSourceProperty");
dataSourceComboColumn.Name = "dataSourceComboColumn";
dataSourceComboColumn.HeaderText = "Data Source";
dataSourceComboColumn.DataSource = this.dataSources;
dataSourceComboColumn.DropDownStyle = RadDropDownStyle.DropDownList;
dataSourceComboColumn.ValueMember = "ID";
dataSourceComboColumn.DisplayMember = "Path";
dataSourceComboColumn.FieldName = "DataSourceProperty";
dataSourceComboColumn.TextAlignment = ContentAlignment.MiddleLeft;
dataSourceComboColumn.Width = 150;
uxgrdBindingsGrid.MasterTemplate.Columns.Add(dataSourceComboColumn);


Thanks,
--Jason

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 01 Nov 2012, 12:07 PM
Hello Jason, 

Thank you for writing.

Please refer to the following documentation article where you can find the requested examples:
http://www.telerik.com/help/winforms/gridview-columns-gridviewcomboboxcolumn.html

Let me know if you need further assistance with this case.

All the best,
Stefan
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
GridView
Asked by
Jason
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or