Sign in to follow this  
Followers 0
d0n

guictrlsetdata with array

3 posts in this topic

I was wonder how do i set data for a large array like this

Me 123
You 321
Jon 3000
Mike 940

i am not sure how to set the data of the whole array, do i have to do this 1 by 1?

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 308, 277, 302, 218)
$Tab1 = GUICtrlCreateTab(8, 8, 289, 257)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Input1 = GUICtrlCreateInput("Input1", 24, 72, 121, 21)
$Combo1 = GUICtrlCreateCombo("Combo1", 24, 40, 145, 25)
$Button1 = GUICtrlCreateButton("Button1", 208, 40, 75, 25, $WS_GROUP)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlSetState(-1,$GUI_SHOW)
$Label1 = GUICtrlCreateEdit("Label1", 16, 40, 180, 217, BitOR($SS_SUNKEN,$WS_VSCROLL))
$Button2 = GUICtrlCreateButton("Button2", 208, 40, 75, 25, $WS_GROUP)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Dim $avArray2[2][2] = [["1","23"],["3","21"]]


Gui()

Func Gui()

    GUICtrlSetOnEvent($Button2, "array1")

    GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

    ; Just idle around
    While 1
        Sleep(10)
    WEnd
EndFunc

Func array1()
    GUICtrlSetData($Label1, $avArray2)
Endfunc


Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            Exit
    EndSelect
EndFunc   ;==>SpecialEvents

Share this post


Link to post
Share on other sites



d0n,

If you want to display an array, your best choice is a ListView - then you can use a loop to fill in the lines. Look here:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>                                                          ; <<<<<<<<<<

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 308, 277, 302, 218)
$Tab1 = GUICtrlCreateTab(8, 8, 289, 257)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Input1 = GUICtrlCreateInput("Input1", 24, 72, 121, 21)
$Combo1 = GUICtrlCreateCombo("Combo1", 24, 40, 145, 25)
$Button1 = GUICtrlCreateButton("Button1", 208, 40, 75, 25, $WS_GROUP)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlSetState(-1,$GUI_SHOW)
$hListView1 = GUICtrlCreateListView("_|_", 16, 40, 180, 217, $LVS_NOCOLUMNHEADER)   ; <<<<<<<<<<
    _GUICtrlListView_SetColumnWidth(-1, 0, 90)                                      ; <<<<<<<<<<
    _GUICtrlListView_SetColumnWidth(-1, 1, $LVSCW_AUTOSIZE_USEHEADER )              ; <<<<<<<<<<
$Button2 = GUICtrlCreateButton("Button2", 208, 40, 75, 25, $WS_GROUP)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $avArray2[2][2] = [["1","23"],["3","21"]]

Gui()

Func Gui()

    GUICtrlSetOnEvent($Button2, "array1")

    GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

    ; Just idle around
    While 1
        Sleep(10)
    WEnd
EndFunc

Func array1()
    For $i = 0 To UBound($avArray2) - 1                                             ; <<<<<<<<<<
        GUICtrlCreateListViewItem($avArray2[$i][0] & "|" & $avArray2[$i][1] , $hListView1) ; <<<<<<<<<<
    Next                                                                            ; <<<<<<<<<<
Endfunc

Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            Exit
    EndSelect
EndFunc   ;==>SpecialEvents

I have marked the changed lines with : <<<<<<<<<< The Help file should explain the syntax, but ask if anything is unclear.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

thank you will try working at it >_

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