The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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?
ADAdministrator Syncfusion Team February 26, 2007 05:47 PM UTC
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
KDKyle DeVoeFebruary 26, 2007 07:11 PM UTC
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?
KDKyle DeVoeFebruary 26, 2007 07:58 PM UTC
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.
{ 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