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.
Syncfusion Feedback

Grid ComboBox Height

Thread ID:

Created:

Updated:

Platform:

Replies:

5909 Jul 23,2003 03:43 PM UTC Jul 28,2003 03:40 PM UTC WinForms 3
loading
Tags: GridControl
Greg Wright
Asked On July 23, 2003 03:43 PM UTC

How can I the height, or default # of items to show, in a grid cell dropdown? Thanks,

Administrator [Syncfusion]
Replied On July 23, 2003 09:44 PM UTC

There is a DropDownRows property that you can set. But since the list can vary from cell to cell, you have to dynamically set this property cell to cell as well.
//C#
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;
		}
	}
}

'VB.NET
    Private Sub GridControl1_CurrentCellShowingDropDown(ByVal sender As Object,   _
                 ByVal e As Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs)  _
                 Handles GridControl1.CurrentCellShowingDropDown
        Try
            Dim grid As GridControlBase = sender
            Dim cc As GridCurrentCell = grid.CurrentCell
            Dim cr As GridComboBoxCellRenderer = cc.Renderer '
            If cc.RowIndex = 6 Then
                CType(cr.ListBoxPart, GridComboBoxListBoxPart).DropDownRows = 4
            ElseIf cc.RowIndex = 4 Then
                CType(cr.ListBoxPart, GridComboBoxListBoxPart).DropDownRows = 7
            ElseIf cc.RowIndex = 2 Then
                CType(cr.ListBoxPart, GridComboBoxListBoxPart).DropDownRows = 10
            Else
                CType(cr.ListBoxPart, GridComboBoxListBoxPart).DropDownRows = 6
            End If
        Catch
        End Try
    End Sub

Greg Wright
Replied On July 28, 2003 01:12 PM UTC

I implemented what you suggested, and initially had problems in getting it to work. It wouldn't change the height of the list at all. I had one cell dropdown with one item in it, and the dropdown list wouldn't even show that one item. After working with it for a while, I discovered that certain fonts cause problems with the dropdown heights. I was using Arial for the grid font. Once I changed it to Tahoma, if worked fine. Would this be a bug?

Administrator [Syncfusion]
Replied On July 28, 2003 03:40 PM UTC

This does seem to be a problem. We are doing an integer calculation to get the number of pixels per row. The truncated don't seem to affect the tohoma font (losing about .12 pixels per row), but does seem to affect the tohoma font (losing about .38 pixels per row). We will have to tweak this calcualtion to avoid this roundoff problem. In the meantime, if you want to use arial, you can just fudge th1 number of rows by 1 Say you really want to see 1 row, request 2 rows...)

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.

Warning Icon 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.Close Icon

;