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 change the dropdown window height of a combobox that is used in a grid control cell

I am using ComboBox cell type in my virtual grid. My question is: Is there a way to set the ComboBox dropdown window height to a larger number when the choicelist is long? For example, if the ComboBox has 10 items, I would like the ComboBox dropdown window expanded to show all 10 items instead of only showing 6 of them with a scrollbar. Thanks dongxian

7 Replies

AD Administrator Syncfusion Team June 25, 2004 12:43 PM UTC

You set the DropDownRows property. This can be done one time in formload if you want all comboboxes to have the same number of rows. But if you need to do it on a cell by cell basis, you can use the CurrentCellShowingDropDown event.
private void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
	GridControlBase grid = sender as GridControlBase;
	if(grid != null)
	{
		GridCurrentCell cc = grid.CurrentCell;
		GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
		if(cc != null)
		{
			if(cc.RowIndex == 6)
			    ((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 4;
			else if(cc.RowIndex == 4)
				((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 7;
			else if(cc.RowIndex == 2)
				((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 10;
			else
				((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 6;
		}
	}
}


DL Dongxian Li June 25, 2004 04:14 PM UTC

I tried your code. It works fine except for a small problem. The dropdown window looks fine when the DropDownRows is less than 8. But when the DropDownRows reaches 8, a extra empty row was added to the dropdown window. When the DropDownRows reaches 16, two extra empty rows were added to the dropdown window. When the DropDownRows reaches 24, three extra empty rows were added to the dropdown window. Looks like one extra empty row is added to the dropdown window every 8 rows. thanks


AD Administrator Syncfusion Team June 25, 2004 08:49 PM UTC

This appears to be a bug. We will get it fixed in our code.


TH Tommy Heath December 15, 2004 07:55 PM UTC

How IS it done in Formload? And how do you set the dropDownRows and or the drop down height for a non-grid comboBoxBase with/without a grid ListControlPart? >You set the DropDownRows property. This can be done one time in formload if you want all comboboxes to have the same number of rows. But if you need to do it on a cell by cell basis, you can use the CurrentCellShowingDropDown event. >
>private void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
>{
>	GridControlBase grid = sender as GridControlBase;
>	if(grid != null)
>	{
>		GridCurrentCell cc = grid.CurrentCell;
>		GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
>		if(cc != null)
>		{
>			if(cc.RowIndex == 6)
>			    ((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 4;
>			else if(cc.RowIndex == 4)
>				((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 7;
>			else if(cc.RowIndex == 2)
>				((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 10;
>			else
>				((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 6;
>		}
>	}
>}
>


AD Administrator Syncfusion Team December 15, 2004 10:36 PM UTC

The reason you normally do it in CurrentCellShowing dropdown is that the same combobox is used for every cell.If you set it in FormLoad, then it will be set for every cell.
private void Form1_Load(object sender, System.EventArgs e)
{
	GridComboBoxCellRenderer cr = this.gridControl1.GetCellRenderer(5, 3) as GridComboBoxCellRenderer;
	((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 2;
}
I think for the comboboxbase, the height of the dropdown is determined by the height of teh ListControl that you are using for your dropdown list.


KB Karsten Brocksieper March 6, 2006 04:58 PM UTC

Hello, I can´t read C# code very well. Therefore it would be very nice if someone can translate the above mentioned code for VB.Net. Thank you very much in advance Karsten >The reason you normally do it in CurrentCellShowing dropdown is that the same combobox is used for every cell.If you set it in FormLoad, then it will be set for every cell. >
>private void Form1_Load(object sender, System.EventArgs e)
>{
>	GridComboBoxCellRenderer cr = this.gridControl1.GetCellRenderer(5, 3) as GridComboBoxCellRenderer;
>	((GridComboBoxListBoxPart)cr.ListBoxPart).DropDownRows = 2;
>}
>
> >I think for the comboboxbase, the height of the dropdown is determined by the height of teh ListControl that you are using for your dropdown list.


AD Administrator Syncfusion Team March 7, 2006 10:40 AM UTC

Hi Karsten, Here is the VB code snippet. '' Form load event Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim cr As GridComboBoxCellRenderer = Me.gridControl1.GetCellRenderer(5,3) CType(cr.ListBoxPart, GridComboBoxListBoxPart).DropDownRows = 2 End Sub '' In CurrentCellShowingDropDown event Private Sub gridControl1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs) Handles gridControl1.CurrentCellShowingDropDown Dim cc As GridCurrentCell = Me.gridControl1.GetCellRenderer(5,3).CurrentCell Dim cr As GridComboBoxCellRenderer = Me.gridControl1.GetCellRenderer(5,3) CType(cr.ListBoxPart, GridComboBoxListBoxPart).DropDownRows = 10 End Sub ''gridControl1_CurrentCellShowingDropDown Let us know if you need further assistance, Best Regards, Madhan.

Loader.
Live Chat Icon For mobile
Up arrow icon