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
close icon

How to add Popupcontrol to dropdown of ComboBox

this.gridGroupingControl1.TableDescriptor.Columns["Description"].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.Combobox; How can i add a popupcontrol to this combobox , and custom this popupcontrol such as popupcontrol high, width , datasource Thank for read and helping me!!!!

3 Replies

PM Piruthiviraj Malaimelraj Syncfusion Team April 14, 2017 06:38 AM UTC

Hi Truong, 

Thanks for the update. 
 
Query 
Response 
 
 
 
 
 
 
 
 
 
 
How can i add a popupcontrol to this combobox and custom this popupcontrol such as popupcontrol high, width , datasource 
We could able to understand your scenario and created the simple sample as per your requirement. You can add the custom controls as you want in ComboBox DropDown by adding the controls in the GridComboBoxCellRenderer.DropDownContainer and also you can customize the dropdown width and height by using e.Inner.Size property in TableControlCurrentCellShowingDropDown event. 
 
 
Code example: 
void gridGroupingControl1_TableControlCurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCurrentCellShowingDropDownEventArgs e) 
{ 
    GridComboBoxCellRenderer renderer = e.TableControl.CurrentCell.Renderer as GridComboBoxCellRenderer; 
    
    ComboBox combo = new ComboBox(); 
    combo.DataSource = dt; 
    combo.DisplayMember = "Value"; 
    combo.ValueMember = "ID"; 
 
    //Remove the default control 
    renderer.DropDownContainer.Controls.RemoveAt(0); 
      
    //Add the GridControl in DropDown. 
    renderer.DropDownContainer.Controls.Add(combo); 
 
    //Change the DropDown width and Height. 
    e.Inner.Size = new Size(200, e.Inner.Size.Height); 
} 


If you want to add the custom controls (i.e GridControl,Calculator, etc.) ,please refer to the dash boards samples from below location,  
<InstalledLocation\Syncfusion\EssentialStudio\VersionNumber\Windows\Grid.Windows\Samples\Custom Cell Types\Drop Down Cell Demo\CS> 

If you want to add the GridListControl directly into ComboBox, please refer to the dash board sample from below location, 
<InstalledLocation\Syncfusion\EssentialStudio\VersionNumber\Windows\Grid.Windows\Samples\Grid List Control\Drop-Down Grid Demo\CS> 
 
Sample link: 

Regards, 
Piruthiviraj 



TR Truong April 19, 2017 08:37 AM UTC

I tried to add GridlistControl but it is not woriking:

 GridComboBoxCellRenderer renderer = e.TableControl.CurrentCell.Renderer as GridComboBoxCellRenderer;
            //Remove the default control 
            renderer.DropDownContainer.Controls.RemoveAt(0);

            //Add the GridControl in DropDown. 
            renderer.DropDownContainer.Controls.Add(gridNguyenLieu);

            //Change the DropDown width and Height. 
            e.Inner.Size = new Size(200, e.Inner.Size.Height); 

I want to add this grid as same as add grid to popupcontrol of combodropdown:

           cbo_HangHoaCha.PopupControl = gridHangHoaCha;



MG Mohanraj Gunasekaran Syncfusion Team April 20, 2017 01:50 PM UTC

Hi Truong, 
 
Thanks for your update. 
 
We can reproduce your scenario. By default, GridListControl size as 0 when initialize the grid. So, the size should be defined before the GridListControl initialization then only which can visible in drop down container. Please refer to the below code example and the attached sample, 
 
Code example 
GridComboBoxCellRendererrenderer = e.TableControl.CurrentCell.Renderer as GridComboBoxCellRenderer; 
             
GridListControl list = new GridListControl(); 
list.DataSource = dt; 
list.DisplayMember = "Value"; 
list.ValueMember = "ID"; 
list.Dock = DockStyle.Fill; 
//(Or) 
//list.Size = new System.Drawing.Size(100, 60); 
//Remove the default control 
renderer.DropDownContainer.Controls.RemoveAt(0); 
//Add the GridControl in DropDown. 
renderer.DropDownContainer.Controls.Add(list); 
             
e.Inner.Size = new Size(200, e.Inner.Size.Height); 
 
Sample link: GridGroupingControl 
 
 
Note: 
By default, GridGroupingControl having the support for GridListCotrol cell type so you can directly use this CellType for grid cells. Please refer to the below code example, 
 
Code example 
this.gridGroupingControl1.TableDescriptor.Columns["Description"].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.GridListControl; 
 
Regards, 
Mohanraj G 
 


Loader.
Live Chat Icon For mobile
Up arrow icon