Ugly GridViewComboBoxColumn

3 posts, 1 answers
  1. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 13 May 2010 Link to this post

    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. Answer
    Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 14 May 2010 Link to this post

    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.
  3. DevCraft banner
  4. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 14 May 2010 Link to this post

    Awesome :)
Back to Top