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

ComboBoxEditor on certain cells

3 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 2
Adam asked on 09 Jul 2010, 06:31 PM
I'm building a property-editor style grid with a readonly column with the name of the property and then an editable column to enter data.  Some of the rows have drop-down values where they have their own unique choice of drop-down entries.  I can get the comboBoxEditor to appear with the following code:

private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
    List<string> fixedValues = GetFixedValues();
    if (fixedValues == null) return; //will use a normal textbox editor for items with no fixedValues
  
    RadComboBoxEditor comboEditor = new RadComboBoxEditor();
    (comboEditor.EditorElement as RadComboBoxEditorElement).DataSource = fixedValues;
  
    e.Editor = comboEditor;
    e.EditorType = typeof(RadComboBoxEditor);         
}

but I am having trouble optimizing the use of the combobox for data entry.  The comboBox loses its value as you tab through the cell without changing anything.  Basically I haven't found any way to set the selected index or the value.  I think it has to do with the Items property never being populated, but I can't get it to populate even though the DataSource is set.

Any ideas?

Thanks,
Adam


3 Answers, 1 is accepted

Sort by
0
Accepted
Martin Vasilev
Telerik team
answered on 14 Jul 2010, 04:06 PM
Hello Adam,

Thank you for writing.

Your code seems right, however I think I managed to reproduce described issue: If you are in edit mode and enter into combo editor through tab press, it shows the first item selected, which is wrong provided that the cell value actually is null. This is related to how the bound to the List object RadComboBoxEditor handles its value. You can avoid this by populating the combo items manually instead of using binding. Please consider the following code:
 
RadComboBoxEditor comboEditor = new RadComboBoxEditor();
//(comboEditor.EditorElement as RadComboBoxEditorElement).DataSource = fixedValues;
foreach (string item in fixedValues)
{
    editorElement.Items.Add(new RadComboBoxItem(item));
}

Let me know if this does not help in your case.

Sincerely yours,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Adam
Top achievements
Rank 2
answered on 14 Jul 2010, 06:18 PM
Martin, 

I want to say that I tried doing it that way and experienced exceptions, however, using your code appears to do the trick.  Thanks so much for your help with this!

-Adam
0
Martin Vasilev
Telerik team
answered on 20 Jul 2010, 06:21 AM
Hello Adam,

I am glad that the provided solution does the job in your case. Do not hesitate to contact me again if you have any other questions.

Sincerely yours,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Adam
Top achievements
Rank 2
Answers by
Martin Vasilev
Telerik team
Adam
Top achievements
Rank 2
Share this question
or