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.

ComboBox List Count

Thread ID:

Created:

Updated:

Platform:

Replies:

57114 Feb 26,2007 12:35 PM Feb 26,2007 02:58 PM Windows Forms 3
loading
Tags: GridControl
Kyle DeVoe
Asked On February 26, 2007 12:35 PM

I need to increase the number of items that are displayed when the user clicks and opens a combobox. Currently the default is six items. I assume there is a way to change the default number of items that are listed. How do I do this?

Kyle

Administrator [Syncfusion]
Replied On February 26, 2007 12:47 PM

Hi Kyle,

Here is a minimal sample that shows you "How to increase the display item count in a combobox cell?".
GC_comboBox.zip

Best regards,
Haneef

Kyle DeVoe
Replied On February 26, 2007 02:11 PM

Haneef,

Thank you for the example. I tried the example and it doesn't fit my needs. I'll try to explain it again, because I don't think I explained it well.

When a user clicks a button to display the list box, the drowp down list will show up to six items from the list. If you have less than six in the list, then obviously it shows the entire list. If you have more, it shows only six, but displays a scrollbar to view the rest of the list. How do I increase the subset of items listed when the drop down displays?

Kyle DeVoe
Replied On February 26, 2007 02:58 PM

I found my answer. I figured I would have to override CurrentCellShowingDropDown() to fix the issue. I was then able to search the documentation until I found a topic called "How to Control the Number of Visible Items in a Combo Box Cell".

How to Control the Number of Visible Items in a Combo Box Cell

Introduction

There is a GridComboBoxListBoxPart.DropDownRows property which, you can set to control this. The GridComboBoxListBoxPart is the actual control type of the list that is dropped to display the items. But, it is buried a little deep and generally needs an event handler to set it. The reason of using an event handler is that normally a single combobox control is shared among all combobox cells. Each cell can potentially have a different list and may need different numbers of visible rows. So to handle this, you must catch the Grid.CurrentCellShowingDropDown event and set the property there depending upon the exact row and column.

Example


[C#]

private void grid_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)

{
GridControlBase grid = sender as GridControlBase;
if(grid != null)
{
GridCurrentCell cc = grid.CurrentCell;
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;

// Set number of visible items for comboboxes in Row 6 as 4, Row 4 as 7, Row 2 as 10 , and so on.
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 Grid_CurrentCellShowingDropDown(sender As Object, e As GridCurrentCellShowingDropDownEventArgs)
Try
Dim grid As GridControlBase = sender
Dim cc As GridCurrentCell = grid.CurrentCell
If cc.Renderer Is GetType(GridComboBoxCellRenderer) Then
Dim cr As GridComboBoxCellRenderer = cc.Renderer

// Set number of visible items for comboboxes in Row 6 as 4, Row 4 as 7, Row 2 as 10 , and so on.
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
End If
Catch
End Try
End Sub

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.

;