tarretarretarre Posted October 10, 2014 Share Posted October 10, 2014 (edited) Hello im trying to create treeViewParents & childs based on what i have selected, it seem not to work properly, childs gets added to random places sometimes, does the array mess it up? or my selection method? Also, when i try to delete, random items always gets deleted, cant really tell what the problem is.. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <GuiTreeView.au3> #include <TabConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <array.au3> Local $aTreeView_Child[1] $aTreeView_Child[0] = 1 #Region ### START Koda GUI section ### Form=c:\program files (x86)\autoit3\scite\koda\forms\script editor.kxf Local $GUI = GUICreate("Form1", 763, 346, 337, 354) $TreeView1 = GUICtrlCreateTreeView(8, 40, 457, 273) $Button1 = GUICtrlCreateButton("Run selected", 8, 8, 83, 25) $Button2 = GUICtrlCreateButton("Save", 96, 8, 75, 25) $Button3 = GUICtrlCreateButton("Delete ", 208, 8, 75, 25) $Button4 = GUICtrlCreateButton("Add", 472, 8, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button4 $tIndex = _GUICtrlTreeView_GetSelIndex($TreeView1) ST_Editor_Add2List($TreeView1, $tIndex) Case $Button3 $tIndex = _GUICtrlTreeView_GetSelIndex($TreeView1) ST_Editor_RemoveFromList($TreeView1, $tIndex) Case $Button1 MsgBox(0, 0, $tIndex) _ArrayDisplay($aTreeView_Child) EndSwitch WEnd Func ST_Editor_Add2List($TreeView, $iParent = 1) _GUICtrlTreeView_BeginUpdate($TreeView) If $iParent > 1 Then _ArrayAdd($aTreeView_Child,_GUICtrlTreeView_AddChild($TreeView, $aTreeView_Child[$iParent], "Test " & Random(1, 10, 1), 0, 0)) Else _ArrayAdd($aTreeView_Child,_GUICtrlTreeView_AddChild($TreeView, 0, "Test " & Random(1, 10, 1), 0, 0)) EndIf _GUICtrlTreeView_EndUpdate($TreeView) $aTreeView_Child[0] = UBound($aTreeView_Child) - 1 EndFunc ;==>ST_Editor_Add2List Func ST_Editor_RemoveFromList($TreeView, $index) _GUICtrlTreeView_Delete($TreeView, $aTreeView_Child[$index]) EndFunc ;==>ST_Editor_RemoveFromList Func _GUICtrlTreeView_GetSelIndex($TreeView) $iIndex = 0 $hItem = _GUICtrlTreeView_GetFirstItem($TreeView) For $i = 0 To _GUICtrlTreeView_GetCount($TreeView) - 1 If _GUICtrlTreeView_GetSelected($TreeView, $hItem) Then $iIndex = $i + 1 ;MsgBox(0,0,$hItem) /?! $hItem = _GUICtrlTreeView_GetNext($TreeView, $hItem) Next MsgBox(64, "", StringFormat("Selected Text: %s\nSelected Index: %i", GUICtrlRead($TreeView, 1), $iIndex), 0, $GUI) Return $iIndex EndFunc ;==>_GUICtrlTreeView_GetSelIndex Edited October 10, 2014 by tarretarretarre Socket-IO - An event-driven TCP UDF (Realtime chat example) AutoIt-API-WS - An expressive HTTP server you can use to build your own API with (Screenshots) Link to comment Share on other sites More sharing options...
MikahS Posted October 10, 2014 Share Posted October 10, 2014 Using code tags [ autoit] ; code here [ /autoit] (minus the spaces) will give you syntax highlighting and formatting. Making it easier for us to see. like so: Local $test = 'test' ; comment Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
tarretarretarre Posted October 10, 2014 Author Share Posted October 10, 2014 oh my mistake, i adjusted it Socket-IO - An event-driven TCP UDF (Realtime chat example) AutoIt-API-WS - An expressive HTTP server you can use to build your own API with (Screenshots) Link to comment Share on other sites More sharing options...
tarretarretarre Posted October 12, 2014 Author Share Posted October 12, 2014 I found the mistake, im just copying the $TreeView, silly me, i used BYREF and it works perfectly ))) Socket-IO - An event-driven TCP UDF (Realtime chat example) AutoIt-API-WS - An expressive HTTP server you can use to build your own API with (Screenshots) 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