Jump to content
Sign in to follow this  
Luigi

_GUICtrlListView_Create, the new item in the first

Recommended Posts

Luigi

Hi forum!

By default, each data inserted in _GUICtrlListView_Create, occupies the last line.

There are some way to put the last item by first?

The new data, always occupythe first line?

Thanks,

Detefon.


Visit my repository

Share this post


Link to post
Share on other sites
kylomas

detefon,

Yes, see comments in code...

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <string.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

; generate test data for 3 columns

local $test_data[10][3]
for $1 = 0 to ubound($test_data) - 1
    $test_data[$1][0] = 'Test Data Entry = ' & stringformat('%02i',$1)
    $test_data[$1][1] = _StringRepeat(chr(random(69,90,1)),5)
    $test_data[$1][2] = _StringRepeat(chr(random(69,90,1)),5)
next

_arraydisplay($test_data)

local $gui010   =   guicreate('ListView Demo')
local $aSize    =   ControlGetPos('','',$gui010)
local $lv010    =   _guictrllistview_create($gui010,'col1|col2|col3',0,0,$aSize[2],$aSize[3])

; resize the columns for even distribution across the control

local $LVsize   =   controlgetpos($gui010,'',$lv010)
for $1 = 0 to _GUICtrlListView_GetColumnCount($lv010) + 1
    _GUICtrlListView_SetColumnWidth($lv010, $1, ($LVSize[2])/_GUICtrlListView_GetColumnCount($lv010))
next

; populate control in push down fashion

for $1 = 0 to ubound($test_data) - 1
    _GUICtrlListView_InsertItem($lv010,$test_data[$1][0],0)     ;   inserts item in first row because index is "0"
    _GUICtrlListView_setitemtext($lv010,0,$test_data[$1][1],1)  ;   sets subitem text for column 1
    _GUICtrlListView_setitemtext($lv010,0,$test_data[$1][2],2)  ;   set subitem txt for column 2
next

guisetstate()

while 1
    switch guigetmsg()
        case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
wend

kylomas

edit: corrected comment

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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
Sign in to follow this  

×