notsure Posted November 27, 2015 Share Posted November 27, 2015 (edited) Hi,I've got a little problem and i was hoping anyone here could help me sort this out.Didn't exactly know whether to put this in GUI help or General Support... but i think its a combination of code and GUI.I've got this (its a lot more, but i stripped to keep it visually comprehensible).$tvRDS = GUICtrlCreateTreeViewItem("150.bla 1", $tvLocations) $tvZDK = GUICtrlCreateTreeViewItem("152. bla 2", $tvLocations) $tvWND = GUICtrlCreateTreeViewItem("153. bla 3", $tvLocations) $tvGAW = GUICtrlCreateTreeViewItem("154.bla 4", $tvLocations) $tvEND = GUICtrlCreateTreeViewItem("155. bla 5", $tvLocations) Global $tvITEM MsgBox(1, "Information", "Count: " & _GUICtrlTreeView_GetCount($tvLocations)) ;Fill treeview with subitems. for $x = 1 to _GUICtrlTreeView_GetCount($tvLocations) $tvITEM = _GUICtrlTreeView_GetText ( $tvLocations, $x) $Nr = stringright($tvItem, 3) ;here needs to be something to put them in the right handle (like $tvRDS if $nr = 150, and $tvWND if $nr = 153) ;ive got multiple excel files (all named 150.xlsx, 151.xlsx etc., so i can use _excelbookopen($nr & ".xlsx") etc Next So i can select excel files by reading the first 3 chars (150, 151, 152 etc.) and open them. The childitems need to be filled with the data in Excel.But to do this, i need to give my handle in the ; $tvRDS = GUICtrlCreateTreeViewItem(*EXCELDATA*, $tvGAW or $tvEND or $tvGAW... )So by reading the excel files, how do i get the correct handle to put it at the right tree item. If you get what i mean? Else i have to do ALL those seperate Like;if $nr = 150 then GUICtrlCreateTreeViewItem(*EXCELDATA*, $tvRDS)if $nr = 152 then GUICtrlCreateTreeViewItem(*EXCELDATA*, $tvZDK) And so on, and so on... there are like 50 locations.Sorry if i confuse you, and will be trying to clarify what i mean if its unclear. Thanks in advance for any help. Notsure. Edited November 27, 2015 by notsure Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 27, 2015 Moderators Share Posted November 27, 2015 notsure,Save the ControlIDs of the TreeView items in an array and then when you get the 3-digit ID you can search the array and find the correct ControlID to use. Here is a basic example script:expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <Array.au3> Global $aItems[5][2] = [["150"], ["152"], ["153"], ["154"], ["155"]] ; Array holding the codes Global $aRadio[5] ; Just for demo $hGUI = GUICreate("Test", 500, 500) $tvLocations = GUICtrlCreateTreeView(10, 10, 400, 300) ; Store the ControlIDs of the TrerView items in the array $aItems[0][1] = GUICtrlCreateTreeViewItem("150.bla 1", $tvLocations) $aItems[1][1] = GUICtrlCreateTreeViewItem("152.bla 2", $tvLocations) $aItems[2][1] = GUICtrlCreateTreeViewItem("153.bla 3", $tvLocations) $aItems[3][1] = GUICtrlCreateTreeViewItem("154.bla 4", $tvLocations) $aItems[4][1] = GUICtrlCreateTreeViewItem("155.bla 5", $tvLocations) ; just for demo GUIStartGroup() For $i = 0 To 4 $aRadio[$i] = GUICtrlCreateRadio($aItems[$i][0], 10, 350 + (20 * $i), 200, 20) Next GUIStartGroup() $cAdd = GUICtrlCreateButton("Add",400, 450, 80, 30) GUISetState() ; Just for interest _ArrayDisplay($aItems, "", Default, 8) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cAdd ; See if a radio is set For $i = 0 To 4 If GUICtrlRead($aRadio[$i]) = $GUI_CHECKED Then ; Read the radio to get the required item for adding - you woudl get this from the Excel file $sParent = GUICtrlRead($aRadio[$i], 1) ; Search for the corerct entry in the array $iIndex = _ArraySearch($aItems, $sParent) ; Create the item GUICtrlCreateTreeViewItem("New " & $sParent & " item " & @SEC, $aItems[$iIndex][1]) ; Refresh the TreeView GUICtrlSetState($tvLocations, $GUI_HIDE) GUICtrlSetState($tvLocations, $GUI_SHOW) ; No point in looking further ExitLoop EndIf Next EndSwitch WEndPlease ask if you have any questions, although I will shortly be away for much of this afternoon.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...
notsure Posted November 27, 2015 Author Share Posted November 27, 2015 Thanks alot Melba. Got it almost working.However, this is about IP addresses to be sorted. So it is possible that more than 1 "hit" needs to be stored in the parent-item.So the construction to add doesn't work that well, as it adds all to all parent entry's. But i'm 1 step further, thanks so far. Link to comment Share on other sites More sharing options...
notsure Posted November 27, 2015 Author Share Posted November 27, 2015 Got it, thanks alot. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 27, 2015 Moderators Share Posted November 27, 2015 notsure,Glad I could I help. Why do you not post the code so people can see what you used?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...
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