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

Ugly GridViewComboBoxColumn

2 Answers 52 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marc Roussel
Top achievements
Rank 2
Marc Roussel asked on 13 May 2010, 04:22 PM
Hi,

I've added a GridViewComboBoxColumn in my grid but my grid rows have a modified high and I don't know how to make the combobox inside the cell to take the entire cell as you can see in this screenshot :

Please give me the simplest way possible as I already have this code to add me a new ComboBoxColumn in the grid :

public static void TelerikAddComboBoxColumn(RadGridView GridView, string FrenchCaption, string EnglishCaption, string SelectedValueMemberPath, string DisplayMemberPath, string DataMemberBinding, bool IsVisible, bool IsReadOnly, double Width, Telerik.Windows.Controls.SortingState SortingState, System.Collections.IEnumerable ItemsSource)  
{  
    GridViewComboBoxColumn NewColumn = new GridViewComboBoxColumn();  
      
    if (FrenchCaption != "")  
        NewColumn.Header = FrenchCaption;  
    else 
        NewColumn.Header = EnglishCaption;  
 
    NewColumn.IsVisible = IsVisible;  
    NewColumn.IsReadOnly = IsReadOnly;  
 
    if (Width != -1)  
        NewColumn.Width = Width;  
 
    NewColumn.SortingState = SortingState;  
 
    // http://www.telerik.com/help/silverlight/gridview-columns-column-types.html#GridViewDynamicHyperlinkColumn  
    //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
    // SelectedValueMemberPath  – This one is used in conjunction with the DisplayMemberPath in the process of translation of value to display content. It also tells the ComboBox editor which property to use as value when the user makes selection.  
    // DisplayMemberPath        – This one is used to translate value to cell content(e.g. the ID of a country to the Name of the country). It points to a field in the GridViewComboBoxColumn.ItemsSource.  
    // DataMemberBinding        - A Binding to a field from the RadGridView.ItemsSource to be displayed in the column.  
    // ItemsSource              – An IEnumerable collection that contains data used to populate the ComboBox editor as well as to translate values when the cell is not in edit mode.  
    //  
    // NOTE : If the combobox is bound to an object, the SelectedValueMemberPath must be empty and the DataMemberBinding binds on the object property  
    //        else the SelectedValueMemberPath and the DataMemberBinding will be the same which is the property only, like the int.  
    //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
    NewColumn.SelectedValueMemberPath = SelectedValueMemberPath;  
    NewColumn.DisplayMemberPath = DisplayMemberPath;  
    NewColumn.DataMemberBinding = new System.Windows.Data.Binding(DataMemberBinding);  
    NewColumn.ItemsSource = ItemsSource;  
 
    GridView.Columns.Add(NewColumn);  
}  
 

2 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 14 May 2010, 10:15 AM
Hi Marc Roussel,

 Here is what you can do to style the RadComboBox editor in the column from code:

NewColumn.EditorStyle = new Style { TargetType = typeof(RadComboBox) };
NewColumn.EditorStyle.Setters.Add(new Setter(RadComboBox.HeightProperty, 50));

This way you can modify any DependencyProperty on the RadComboBox in the GridViewComboBoxColumn.

Sincerely yours,
Yavor Georgiev
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
Marc Roussel
Top achievements
Rank 2
answered on 14 May 2010, 10:35 PM
Awesome :)
Tags
GridView
Asked by
Marc Roussel
Top achievements
Rank 2
Answers by
Yavor Georgiev
Telerik team
Marc Roussel
Top achievements
Rank 2
Share this question
or