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.

How to change the dropdown window height of a combobox that is used in a grid control cell

Thread ID:

Created:

Updated:

Platform:

Replies:

15727 Jun 25,2004 08:18 AM Mar 7,2006 05:40 AM Windows Forms 7
loading
Tags: GridControl
Dongxian Li
Asked On June 25, 2004 08:18 AM

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

Administrator [Syncfusion]
Replied On June 25, 2004 08:43 AM

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

Dongxian Li
Replied On June 25, 2004 12:14 PM

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

Administrator [Syncfusion]
Replied On June 25, 2004 04:49 PM

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

Tommy Heath
Replied On December 15, 2004 02:55 PM

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

Administrator [Syncfusion]
Replied On December 15, 2004 05:36 PM

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.

Karsten Brocksieper
Replied On March 6, 2006 11:58 AM

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.

Administrator [Syncfusion]
Replied On March 7, 2006 05:40 AM

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.

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.

;