We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridControl ComboBox Scrollbar Office theme

Hello, 

I would like for the vertical scrollbar in a GridControl ComboBox cell to have the same theme(Office2007, Office2010, Metro etc) as the underlying GridControl. However, the scrollbar for the ComboBox cell just seems to be a standard gray scroll bar. 

Could you please let me know how I can achieve this? 

Thanks,
Taylour

using System.Linq;
using System.Windows.Forms;
using Syncfusion.Windows.Forms;
using Syncfusion.Windows.Forms.Grid;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            var gridControl = new GridControl();
            gridControl.HScrollPixel = true;
            gridControl.VScrollPixel = true;
            gridControl.RowCount = 20;
            gridControl.ColCount = 10;
            gridControl.Dock = DockStyle.Fill;
            gridControl.GridVisualStyles = GridVisualStyles.Office2007Blue;
            gridControl.ColorStyles = ColorStyles.Office2007Blue;
            gridControl.GridOfficeScrollBars = OfficeScrollBars.Office2007;
            gridControl.Office2007ScrollBarsColorScheme = Office2007ColorScheme.Blue;
            gridControl.Office2007ScrollBars = true;
            gridControl.ThemesEnabled = true;
            gridControl[1, 1].CellType = GridCellTypeName.ComboBox;
            gridControl[1, 1].DataSource = Enumerable.Range(1, 20).ToList();
            Controls.Add(gridControl);
        }
    }

5 Replies

AK Adhikesevan Kothandaraman Syncfusion Team June 10, 2016 02:21 PM UTC

Hi Taylour, 
 
Thanks for using Syncfusion products. 
 
By default the ComboBox dropdown will display the scrollbars only in system theme. If you want to apply the different theme for dropdown scrollbar, you can use the GridListControl as the CellType instead of the ComboBox. Please refer to the following code snippet and sample, 
 
 
Code Snippet: 
//Set the cell type as GridListControl 
this.gridControl1[2, 3].CellType = GridCellTypeName.GridListControl; 
this.gridControl1[2, 3].DataSource = collection; 
 
GridDropDownGridListControlCellRenderer renderer = this.gridControl1.CellRenderers["GridListControl"] as GridDropDownGridListControlCellRenderer; 
if(renderer!= null ) 
{   //Apply the theme for the GridListControl scrollbar  
    renderer.ListControlPart.Grid.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro; 
    //Hide the column header 
    renderer.ListControlPart.ShowColumnHeader = false; 
} 


Sample: 

Regards, 
Adhi 



TT tttmack June 10, 2016 04:12 PM UTC

Hi Adhi,

thanks for the sample code. How can I get the width of the GridListControl dropdown to behave the same way as a ComboBox cell? In a ComboBox cell, the drop down width will be Max(columnWidth, max text width in the cell's datasource).

I tried this code, but it has no effect. Additionally even if it did work, I would need to edit the width every time the user manually resizes a column which seems overly complicated.
renderer.ListControlPart.AutoSizeColumns = false;
renderer.ListControlPart.Grid.ColWidths[1] = gridControl1.ColWidths[3];

What is the best way to achieve this?

Thanks,
Taylour


AK Adhikesevan Kothandaraman Syncfusion Team June 13, 2016 12:36 PM UTC

Hi Taylour, 
 
Thanks for your update. 
 
If you want to change the dropdown width of the GridListControl dynamically while resizing the columns, you can use the CurrentCellShowingDropDown event. Please refer to the following code snippet,  
 
Code snippet: 
this.gridControl1.CurrentCellShowingDropDown += gridControl1_CurrentCellShowingDropDown; 
 
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e) 
{ 
    GridDropDownGridListControlCellRenderer renderer = this.gridControl1.CellRenderers["GridListControl"] as GridDropDownGridListControlCellRenderer; 
    if(renderer != null) 
    { 
        this.renderer.ListControlPart.Grid.ColWidths.ResizeToFit(GridRangeInfo.Col(1)); 
        //Get the resized width of the GridList column  
        int width = this.renderer.ListControlPart.Grid.ColWidths[1]; 
        //Set the width of the dropdown list 
        e.Size = new Size(Math.Max(this.gridControl1.ColWidths[renderer.ColIndex], width), e.Size.Height); 
    } 
} 
 
Sample: 
 
Regards, 
Adhi 



TT tttmack June 13, 2016 03:57 PM UTC

Thank You Adhi!


AK Adhikesevan Kothandaraman Syncfusion Team June 14, 2016 04:27 AM UTC

Hi Taylour, 

Thanks for your update. 

Please let us know, if you need any further assistance.  

Regards, 
Adhi 


Loader.
Up arrow icon