theolonghair Posted October 9, 2013 Share Posted October 9, 2013 -Hello this is my first topic. If this topic is in wrong place put it elsewhere, sorry. When I have a few lines in a listbox, click one to select it, would it be possible that I saw data in another window, e,g an edit box (or you suggest something better). I used a small example, If more info is needed it will take a short while. I found a tree to be a bit to small. Concept would be -listbox- Person a, (line 1) Person b, (line 2) ------------------ Than what will be seen in a different box (currently chose editbox) are things like age, playtime for both persons individual stats and so line1 will show different info than line2: -edit box- Age: Playtime: ----------------- Greetings Theolonghair, Ned Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 9, 2013 Moderators Share Posted October 9, 2013 theolonghair,Welcome to the AutoIt forum. Perhaps this might give you some inspiration:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <GuiListBox.au3> ; Create array to hold edit ControlIDs Global $aEdit[3] ; Create array to hold individual data Global $aData[5][3] = [ _ ["Person 0", 20, "2:30"], _ ["Person 1", 21, "2:31"], _ ["Person 2", 22, "2:32"], _ ["Person 3", 23, "2:33"], _ ["Person 4", 24, "2:34"]] ; Name Age Time ; Pull names from array $sData = "" For $i = 0 To UBound($aData) - 1 $sData &= "|" & $aData[$i][0] Next ; Create GUI $hGUI = GUICreate("Test", 500, 500) $cList = GUICtrlCreateList("", 10, 10, 200, 220, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_MULTIPLESEL)) GUICtrlSetData($cList, $sData) For $i = 1 To 2 $aEdit[$i] = GUICtrlCreateEdit("", 250, (110 * $i) - 100, 240, 100, $ES_READONLY) Next $cClear = GUICtrlCreateButton("Clear", 10, 250, 80, 30) $cRead = GUICtrlCreateButton("Read", 100, 250, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cRead ; Get selected items $aSel = _GUICtrlListBox_GetSelItems($cList) ; Check there are only 2 If $aSel[0] = 2 Then ; For each selceted item For $i = 1 To 2 ; Get index $iIndex = $aSel[$i] ; Extract data from the array $sData = "|" & $aData[$iIndex][0] & @CRLF & $aData[$iIndex][1] & @CRLF & $aData[$iIndex][2] ; And add to edits GUICtrlSetData($aEdit[$i], $sData) Next EndIf ; Clear selections ContinueCase Case $cClear ; Clear selections For $i = 0 To UBound($aData) - 1 _GUICtrlListBox_SetSel($cList, $i, False) Next EndSwitch WEndPlease ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
theolonghair Posted October 16, 2013 Author Share Posted October 16, 2013 Thank you very much. And thanks also for welcoming me. I was semi-doubting my post was not clear enough. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 16, 2013 Moderators Share Posted October 16, 2013 theolonghair,I am delighted that I did understand correctly and could produce something useful - I did have my doubts! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
theolonghair Posted October 19, 2013 Author Share Posted October 19, 2013 and what do I do if I want it with one editlist instead of having to click two persons every time? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 19, 2013 Moderators Share Posted October 19, 2013 theolonghair,Do you mean just you want to have just the one edit which displays the selected person's info? If so then just remove the loops and create/fill a single edit instead of the two that are there at present. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
theolonghair Posted October 19, 2013 Author Share Posted October 19, 2013 hmm, haha got no clue how to realise that. Im sorry to be such a burden. I dont see where the loop starts/ends. Though you are correct about what I asked. Global $aData[5][3] = [ _ ["Person 0", 20, "2:30"], _ ["Person 1", 21, "2:31"], _ ["Person 2", 22, "2:32"], _ ["Person 3", 23, "2:33"], _ ["Person 4", 24, "2:34"]] and do I change the 3 in a 4 when I want more Lines in the editbox displayed? Greetings From Netherlands. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 20, 2013 Moderators Share Posted October 20, 2013 theolonghair,As it appears that you have little coding knowledge (and that is nto a problem as we all began at that point) you really should read the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) - this will help you to understand more about AutoIt syntax and code structure. You should also look at this excellent tutorial - you will find other tutorials in the Wiki (the link is at the top of the page). But this is how you might modify the code I gave you above for a single selection: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <GUIListBox.au3> #include <Array.au3> ; Create array to hold edit ControlIDs ; Global $aEdit[3] ; No longer needed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Create array to hold individual data Global $aData[5][3] = [ _ ["Person 0", 20, "2:30"], _ ["Person 1", 21, "2:31"], _ ["Person 2", 22, "2:32"], _ ["Person 3", 23, "2:33"], _ ["Person 4", 24, "2:34"]] ; Name Age Time ; Pull names from array $sData = "" For $i = 0 To UBound($aData) - 1 $sData &= "|" & $aData[$i][0] Next ; Create GUI $hGUI = GUICreate("Test", 500, 500) $cList = GUICtrlCreateList("", 10, 10, 200, 220, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL)) ; $LBS_MULTIPLESEL no longer needed GUICtrlSetData($cList, $sData) ; Remove first loop <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;For $i = 1 To 2 ; $aEdit[$i] = GUICtrlCreateEdit("", 250, (110 * $i) - 100, 240, 100, $ES_READONLY) ;Next ; Create single Edit control <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $cEdit = GUICtrlCreateEdit("", 250, 10, 240, 100, $ES_READONLY) ;$cClear = GUICtrlCreateButton("Clear", 10, 250, 80, 30) ; No longer needed <<<<<<<<<<<<<<<<<<<<<<< $cRead = GUICtrlCreateButton("Read", 100, 250, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cRead ; And remove second loop <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #cs ; Get selected items $aSel = _GUICtrlListBox_GetSelItems($cList) ; Check there are only 2 If $aSel[0] = 2 Then ; For each selceted item For $i = 1 To 2 ; Get index $iIndex = $aSel[$i] ; Extract data from the array $sData = "|" & $aData[$iIndex][0] & @CRLF & $aData[$iIndex][1] & @CRLF & $aData[$iIndex][2] ; And add to edits GUICtrlSetData($aEdit[$i], $sData) Next EndIf ; Clear selections ContinueCase #ce ; Check there is a selection $sListData = GUICtrlRead($cList) ; Check there was a selection If $sListData Then ; Get index $iIndex = _ArraySearch($aData, $sListData) If Not @error Then ; Extract data from the array $sData = $aData[$iIndex][0] & @CRLF & $aData[$iIndex][1] & @CRLF & $aData[$iIndex][2] ; And add to edits GUICtrlSetData($cEdit, $sData) EndIf EndIf EndSwitch WEndAs to adding elements to the array, I suggest you first read the Arrays tutorial in the Wiki and see if you can work it out yourself. You know where I am if you cannot. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
theolonghair Posted October 20, 2013 Author Share Posted October 20, 2013 (edited) I will thank you <3 -omg the little code beneath helped out so much. I couldn't figure out why my 4th array didn't appear in the box. And I added another "data index" thing and it worked. haha feels good to do it myself. state= *estatic* XD ; Extract data from the array $sData = $aData[$iIndex][0] & @CRLF & $aData[$iIndex][1] & @CRLF & $aData[$iIndex][2] ; And add to edits Edited October 20, 2013 by theolonghair Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now