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

Dynamically add combobox to cell

3 Answers 85 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 24 May 2010, 07:11 PM
Hi:

I have a RadGridView that essentially creates a property page.  Mostly, these are just text entries with some validation for integers, doubles, etc.  However, I have one row that requires a dropdown.  I'm looking at the BeginningEdit event and trying to figure out how I can make the dropdown appear over the cell I want to edit.  Then I define a selection changed event to store the resulting selection away and to populate the cell with the new value.

The start of my code looks like this:
                RadComboBox combo = new RadComboBox();  
                combo.Items.Add( new RadComboBoxItem(){ Content = new TextBlock(){ Text = "Banner" } } );  
                combo.Items.Add( new RadComboBoxItem(){ Content = new TextBlock(){ Text = "HTML" } } );  
                combo.Items.Add( new RadComboBoxItem(){ Content = new TextBlock(){ Text = "PDF" } } );  
                combo.SelectionChanged += new Telerik.Windows.Controls.SelectionChangedEventHandler(combo_SelectionChanged);  
                e.Cell...     // how to I make the combobox appear over the cell?  
 
I don't want to define a contenttemplate for the whole column, just for one cell, so I think I need to do it dynamically.  How can I accompliish this?

Thanks in advance,

Terry


3 Answers, 1 is accepted

Sort by
0
MiddleTommy
Top achievements
Rank 1
answered on 24 May 2010, 10:02 PM
I am a little lost on what you are trying to do.
1) Are you trying to have a combobox sometimes as the editor? and sometimes something else like a textbox?
or
2) Are you trying to have the items in the combobox change dynamically according to the row being edited?
0
Terry
Top achievements
Rank 1
answered on 24 May 2010, 10:20 PM
Case 1.  Usually we will edit via the standard textbox, but for one particular row, we will use a combobox when editing the second column.
0
Vlad
Telerik team
answered on 25 May 2010, 07:30 AM
Hi,

The best approach will be to define your own column, override CreateCellEditElement and return desired control. You can check my blog post for more info:
http://blogs.telerik.com/vladimirenchev/posts/10-05-13/how_to_custom_percentage_column_with_radgridview_radprogressbar_and_radslider_for_silverlight_and_wpf.aspx

Greetings,
Vlad
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
Terry
Top achievements
Rank 1
Answers by
MiddleTommy
Top achievements
Rank 1
Terry
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or