Jump to content

How to increase the number of items displayed in a dropdown box


Darien
 Share

Go to solution Solved by Melba23,

Recommended Posts

Hello,

When I open a drop-down box, a maximum of 30 items are displayed on the screen at once (and there is space on the screen to display more). To show more items, I have to go down with the arrow.

Is there any way to show more than 30 items or to display a scroll bar on the right?

Link to comment
Share on other sites

  • Moderators
  • Solution

Darien,

I get a scroll bar displayed as soon as I go over 30 items:

#include <GUIConstantsEx.au3>

GUICreate("Test", 300, 100)

$Combo = GUICtrlCreateCombo("", 10, 30, 280, 25)
For $i = 1 To 31
    GUICtrlSetData($Combo, "Combo Item Number: " & $i)
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Combo
            ConsoleWrite(GUICtrlRead($Combo) & @CRLF)
    EndSwitch
WEnd

And you change the number of displayed items like this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>

; Create 25 data items
$sData = "|"
For $i = 1 To 45
    $sData &= $i & "|"
Next

$hGUI = GUICreate("Test", 500, 500)

; Create the combo with a read-only edit field and a scrollbar
$hCombo = GUICtrlCreateCombo("", 10, 10, 100, 20, BitOr($CBS_DROPDOWNLIST, $WS_VSCROLL))
; Set number of visible items
GUICtrlSendMsg($hCombo, $CB_SETMINVISIBLE, 40, 0)
GUICtrlSetData($hCombo, $sData)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Hope that helps,

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

1 hour ago, Darien said:

For me the scrollbar only appeared when I used the $WS_VSCROLL parameter (which is not in the AutoIt help).

It's in the help , see : https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateCombo.htm

 

GUICtrlCreateCombo ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text The text which will appear in the combo control.
left The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width [optional] The width of the control (default is the previously used width).
height [optional] The height of the control (default is the previously used height).
style [optional] Defines the style of the control. See GUI Control Styles Appendix.
    default (-1) : $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL
    forced style : $WS_TABSTOP
exStyle [optional] Defines the extended style of the control. See Extended Style Table.
    default ( -1) : $WS_EX_CLIENTEDGE

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...