faustf

listview slow with color line

5 posts in this topic

hi guy i have  a prog  ,  notice  , when  i take data from db   and insert in listview with  guctrlsetbkcolor  is  very slow  with 24 record  i wait  7  or 8 second  and blinking  the listview 

with out  color  go   fast 

this is  my code 

Func _Popola_Anagrafica() ; popola il listview con i clienti del db

    _Mysql_Query("SELECT * FROM ge_anagrafica_clienti ")
    Local $ANAC_cotrol = 0
    Local $ANAC_index = (_ArrayMaxIndex($aRecordsetContent) + 1)
    Do
        GUICtrlCreateListViewItem($aRecordsetContent[$ANAC_cotrol][1] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][2] & "|" & $aRecordsetContent[$ANAC_cotrol][3] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][4] & "|" & $aRecordsetContent[$ANAC_cotrol][5] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][6] & "|" & $aRecordsetContent[$ANAC_cotrol][7] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][8] & "|" & $aRecordsetContent[$ANAC_cotrol][9] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][10] & "|" & $aRecordsetContent[$ANAC_cotrol][11] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][12] & "|" & $aRecordsetContent[$ANAC_cotrol][13] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][14] & "|" & $aRecordsetContent[$ANAC_cotrol][15] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][16] & "|" & $aRecordsetContent[$ANAC_cotrol][17] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][18] & "|" & $aRecordsetContent[$ANAC_cotrol][19] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][20] & "|" & $aRecordsetContent[$ANAC_cotrol][21] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][22] & "|" & $aRecordsetContent[$ANAC_cotrol][23] & "|" & _
                $aRecordsetContent[$ANAC_cotrol][24] & "|" & $aRecordsetContent[$ANAC_cotrol][0], $ANAC_List1)
        If Not Mod($ANAC_cotrol, 2) Then
            ;Even
            GUICtrlSetBkColor(-1, 0xffffff)
        Else
            ;Odd
            GUICtrlSetBkColor(-1, 0xe6e6e6)
        EndIf
        $ANAC_cotrol += 1
    Until $ANAC_cotrol = $ANAC_index
EndFunc   ;==>_Popola_Anagrafica

how  can  optimize ??? 

 

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

simply  genius :D   thnakz  is  very very fast  788  milli second  before   , and  after  78 milli :lmao::lmao::lmao: thankzzz

Share this post


Link to post
Share on other sites

It's no need to check for odd or evenlines. This script shows how to alternate colors in LV:

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <File.au3>

Global $main = GUICreate("Altenating Colors in Listview", 600, 400)
Global $listview = GUICtrlCreateListView("Gruppe1| BlubText", 10, 10, 580, 370, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE))
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; general for alternate Colors
GUICtrlSetBkColor(-1, 0xE6E6FA) ; Backgroundcolor odd Lines
_GUICtrlListView_BeginUpdate($listview)
For $i = 1 To 99
    GUICtrlCreateListViewItem("test" & $i & " |Blub " & Random(1, 9), $listview)
    GUICtrlSetBkColor(-1, 0xcccccc) ;Backgroundcolor even Lines
Next
_GUICtrlListView_EndUpdate($listview)

GUISetState()
Global $msg

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

 

Share this post


Link to post
Share on other sites

I described alternate colors in LVs here:

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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