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.
Unfortunately, activation email could not send to your email. Please try again.

GridControl ComboBox Scrollbar Office theme

Thread ID:

Created:

Updated:

Platform:

Replies:

124439 Jun 9,2016 07:13 PM Jun 14,2016 12:27 AM Windows Forms 5
loading
Tags: GridControl
tttmack
Asked On June 9, 2016 07:13 PM

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);
        }
    }

Adhikesevan Kothandaraman [Syncfusion]
Replied On June 10, 2016 10:21 AM

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 


tttmack
Replied On June 10, 2016 12:12 PM

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

Adhikesevan Kothandaraman [Syncfusion]
Replied On June 13, 2016 08:36 AM

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 


tttmack
Replied On June 13, 2016 11:57 AM

Thank You Adhi!

Adhikesevan Kothandaraman [Syncfusion]
Replied On June 14, 2016 12:27 AM

Hi Taylour, 

Thanks for your update. 

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

Regards, 
Adhi 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;