Jump to content

listview slow with color line


Recommended Posts

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

 

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

 

Link to comment
Share on other sites

I described alternate colors in LVs here:

 

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