Jump to content

Looking for the fastest way to build a Combobox list


Recommended Posts

I am adding a large list of data to a combobox dropdown (mainly because I want the list be visible beyond the thin GUI height).

The list is then filtered, based on what the user enters in the edit box (a reducing list).

Rebuilding the dropdown list is causes the list to 'flicker' because it is cleared then re-shown.

_GUICtrlComboBox_BeginUpdate has reduced the flicker a bit - however, I am looking for a way to reduce this further.

Any ideas?

I have looked into the _GUICtrlComboBox & _GUICtrlComboBoxEx options and these are slower  than the GUICtrlSetData options:

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <GuiComboBoxEx.au3>

Local $hGui = GUICreate("")

local $t
local $text = ""
local $y = 0

$t=TimerInit()
local $hCombo_Add = _GUICtrlComboBox_Create($hGui,"",0,$y)
$y += 40
for $i=1 to 4500
    _GUICtrlComboBox_AddString($hCombo_Add,$i)
next
ConsoleWrite("_GUICtrlComboBox_AddString:" & TimerDiff($t)&@crlf)

$t=TimerInit()
$text = ""
for $i=1 to 4500
    $text &= $i & "|"
next
local $hCombo_Create = _GUICtrlComboBox_Create($hGui,$text,0,$y)
$y += 40
ConsoleWrite("_GUICtrlComboBox_Create:" & TimerDiff($t)&@crlf)

$t=TimerInit()
local $hComboEx_Add = _GUICtrlComboBoxEx_Create($hGui,"",0,$y)
$y += 40
for $i=1 to 4500
    _GUICtrlComboBoxEx_AddString($hComboEx_Add,$i)
next
ConsoleWrite("_GUICtrlComboBoxEx_AddString:" & TimerDiff($t)&@crlf)

$t=TimerInit()
$text = ""
for $i=1 to 4500
    $text &= $i & "|"
next
local $hComboEx_Create = _GUICtrlComboBoxEx_Create($hGui,$text,0,$y)
$y += 40
ConsoleWrite("_GUICtrlComboBoxEx_Create:" & TimerDiff($t)&@crlf)

$t=TimerInit()
$text = ""
for $i=1 to 4500
    $text &= $i & "|"
next
GUICtrlCreateCombo("",0,$y)
$y += 40
GUICtrlSetData(-1,$text)
ConsoleWrite("GUICtrlSetData:"&TimerDiff($t)&@crlf)

GUISetState()

 While 1
      If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
Link to comment
Share on other sites

Have a look at GUICtrlSetData to update the ComboBox with a single call.

_GUI* (UDF) functions are slower than GUI* functions because the UDF functions are implemented in pure AutoIt whereas the GUI* functions are written in C++.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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