Sign in to follow this  
Followers 0
Hideous

Help with arrays!

4 posts in this topic

Hi there!

Since i was trying all kind of stuff to get the code to work ( and apparently.. it didnt worked out ) I thought off asking the pro's :wacko:.

I need to write an array to a listview item ( see code )... :D

#include <GUIConstants.au3>
#include <Array.au3>


Opt("GUIOnEventMode", 1)

Dim $Customer_Array[3]
$Customer_Array[0] = "Pascal Hendrikse"
$Customer_Array[1] = "Peter Jansen"
$Customer_Array[2] = "Jhon Peters"

$GUI = GUICreate("Customers", 600, 400, 100, 100 )

$ListView1 = GUICtrlCreateListView("Name                    ", 10, 10, 580, 300, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_FULLROWSELECT))
GUICtrlSetData( $Listview1, $Customer_Array )
GUICtrlSetResizing(-1, 100)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState()

GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

    
While 1
    sleep(10)
WEnd
    
Func ArraySort()
    _ArraySort( $Customer_Array )
    GUICtrlSetData( $Listview1, $Customer_Array )
EndFunc

Func Close()
    Exit
EndFunc

[u]Its all about experience...[/u]...

Share this post


Link to post
Share on other sites



Hi there!

Since i was trying all kind of stuff to get the code to work ( and apparently.. it didnt worked out ) I thought off asking the pro's :D.

I need to write an array to a listview item ( see code )... :D

#include <GUIConstants.au3>
#include <Array.au3>
Opt("GUIOnEventMode", 1)

Dim $Customer_Array[3]
$Customer_Array[0] = "Pascal Hendrikse"
$Customer_Array[1] = "Peter Jansen"
$Customer_Array[2] = "Jhon Peters"

$GUI = GUICreate("Customers", 600, 400, 100, 100 )

$ListView1 = GUICtrlCreateListView("Name                    ", 10, 10, 580, 300, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_FULLROWSELECT))
GUICtrlSetData( $Listview1, $Customer_Array )
GUICtrlSetResizing(-1, 100)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState()

GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

    
While 1
    sleep(10)
WEnd
    
Func ArraySort()
    _ArraySort( $Customer_Array )
    GUICtrlSetData( $Listview1, $Customer_Array )
EndFunc

Func Close()
    Exit
EndFuncoÝ÷ Ûú®¢×£¢ëZºÚ"µÍÌÍÐÝÝÛYÓÝH   ÌÍÐÝÝÛYÐ^VÌH    [È ][ÝÈ  ][ÝÈ  [È ÌÍÐÝÝÛYÐ^VÌWH   [È ][ÝÈ  ][ÝÈ  [È ÌÍÐÝÝÛYÐ^VÌHÕRPÝÙ]]J ÌÍÓÝY]ÌK   ÌÍÐÝÝÛYÓÝ

:wacko:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

or,

;_ArrayToListView.au3
#include <GUIConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>


;Opt("GUIOnEventMode", 1)

Dim $Customer_Array[3]
$Customer_Array[0] = "Pascal Hendrikse"
$Customer_Array[1] = "Peter Jansen"
$Customer_Array[2] = "Jhon Peters"

GUICreate("listview items",320,250, 100,200,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF)  ; will change background color

$listview = GUICtrlCreateListView ("col1                  |Last    |First    ",10,10,300,150,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton ("Value?",75,170,70,20)
for $i=0 to UBound($Customer_Array)-1
    $ar_NamesOnLine=StringSplit($Customer_Array[$i]," ")
    GUICtrlCreateListViewItem($Customer_Array[$i]&"|"&$ar_NamesOnLine[2]&"|"&$ar_NamesOnLine[1],$listview)
Next
GUICtrlSetState(-1,$GUI_DROPACCEPTED)   ; to allow drag and dropping
GUISetState()
Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ]

Do
  $msg = GUIGetMsg ()
     
   Select
      Case $msg = $button
         MsgBox(0,"listview item",GUICtrlRead(GUICtrlRead($listview)),1)
      Case $msg = $listview
         ;MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),1)
         _GUICtrlListViewSort($listview,$B_DESCENDING,GUICtrlGetState($listview))
   EndSelect
Until $msg = $GUI_EVENT_CLOSE
Best, Randallc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Heya!

After some scripting I worked the next script out :wacko:

#include <GUIConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>

Opt("GUIOnEventMode", 1)

Dim $Customer_Array[3]
$Customer_Array[0] = "Pascal Hendrikse | Voorschoten"
$Customer_Array[1] = "Peter Jansen | Leiden"
$Customer_Array[2] = "Jhon Peters | Voorschoten"

$GUI = GUICreate("Customers", 600, 400, 100, 100, -1, $WS_EX_ACCEPTFILES)

$ListView1 = GUICtrlCreateListView("Name                    |City                    ", 10, 10, 580, 300, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_FULLROWSELECT))
for $i=0 to UBound($Customer_Array)-1
    GUICtrlCreateListViewItem($Customer_Array[$i],$listview1)
Next
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState()
Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview1) ]

GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
GUICtrlSetOnEvent( $Listview1, "ArraySort" )
    
While 1
    sleep(10)
WEnd
    
Func ArraySort()
    _GUICtrlListViewSort($listview1,$B_DESCENDING,GUICtrlGetState($listview1))
EndFunc

Func Close()
    Exit
EndFunc

I'm gratefull to you :D thank you rlly!

Edited by Hideous

[u]Its all about experience...[/u]...

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  
Followers 0