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

Showing Combobox Items on load

1 Answer 11 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 1
Joshua asked on 09 Jul 2018, 11:40 AM
I Have creating my combobox column and then assigned the items after that as this is how my program worked previously and cannot be changed,however when i load the form there is no default item selected in the combo box ,how do i set a default value to always populate the Combo Box with the first item in the list

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Jul 2018, 11:58 AM
Hello, Joshua,   

The following help article demonstrates a sample approach how to setup properly the GridViewComboBoxColumn: https://docs.telerik.com/devtools/winforms/gridview/columns/column-types/gridviewcomboboxcolumn

It is important to specify the DataSource collection event though the collection may be filled in the Load event of the form for example. In addition, in the CellEditorInitialized you can specify the DataSource as well. However, in order to store the editor's value after exiting edit mode, the selected item has to valid and present in the applied GridViewComboBoxColumn.DataSource collection:
private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    RadDropDownListEditor ddl = e.ActiveEditor as RadDropDownListEditor;
    if (ddl != null)
    {
        RadDropDownListEditorElement el = ddl.EditorElement as RadDropDownListEditorElement;
        el.DataSource = this.productsBindingSource;
        el.DisplayMember = "ProductName";
        el.ValueMember = "ProductID";
    }
}

If you have any further questions I would kindly ask you to submit a support ticket. Thnak you for your understanding.

I hope this information helps.

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 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
Joshua
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or