#include #include #include #include #include Global $aClient[6][5] $aClient[0][0] = 5 ; dont work $aClient[1][0] = "3" $aClient[1][1] = "33" $aClient[1][2] = "333" $aClient[1][3] = "3333" $aClient[1][4] = "33333" $aClient[2][0] = "2" $aClient[2][1] = "22" $aClient[2][2] = "333" $aClient[2][3] = "2222" $aClient[2][4] = "55555" $aClient[3][0] = "4" $aClient[3][1] = "44" $aClient[3][2] = "444" $aClient[3][3] = "4444" $aClient[3][4] = "44444" $aClient[4][0] = "2" $aClient[4][1] = "22" $aClient[4][2] = "222" $aClient[4][3] = "3333" ; <- here $aClient[4][4] = "44444" $aClient[5][0] = "2" $aClient[5][1] = "22" $aClient[5][2] = "222" $aClient[5][3] = "2222" ; <- here $aClient[5][4] = "22222" ;~ ; dont work ;~ $aClient[1][0] = "40" ;~ $aClient[1][1] = "41" ;~ $aClient[1][2] = "42" ;~ $aClient[1][3] = "43" ;~ $aClient[1][4] = "44" ;~ $aClient[2][0] = "20" ;~ $aClient[2][1] = "21" ;~ $aClient[2][2] = "22" ;~ $aClient[2][3] = "23" ;~ $aClient[2][4] = "24" ;~ $aClient[3][0] = "10" ;~ $aClient[3][1] = "11" ;~ $aClient[3][2] = "12" ;~ $aClient[3][3] = "13" ;~ $aClient[3][4] = "14" ;~ $aClient[4][0] = "20" ;~ $aClient[4][1] = "21" ;~ $aClient[4][2] = "22" ;~ $aClient[4][3] = "21" ;~ $aClient[4][4] = "24" ; <- here ;~ $aClient[5][0] = "20" ;~ $aClient[5][1] = "21" ;~ $aClient[5][2] = "22" ;~ $aClient[5][3] = "21" ;~ $aClient[5][4] = "22" ; <- here Global $hGUI = GUICreate("TreeView sort problem", 1050, 800, -1, -1) Global $idTreeview = _GUICtrlTreeView_Create ( $hGUI, 10, 30, 300, 400, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $WS_TABSTOP), $WS_EX_CLIENTEDGE) Global $hTreeview = ControlGetHandle( $hGui, "", $idTreeview) _GUICtrlTreeView_BeginUpdate($hTreeview) for $i=1 to $aClient[0][0] create_entry($i) Next _GUICtrlTreeView_Sort($hTreeview) _GUICtrlTreeView_EndUpdate($hTreeview) GUISetState(@SW_SHOW) While 1 $idMsg = GUIGetMsg() Select Case $idMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() Exit Func create_entry($Index) Local $sCity = $aClient[$Index][0] Local $sBuilding = $aClient[$Index][1] Local $sFloor = $aClient[$Index][2] Local $sZone = $aClient[$Index][3] Local $sHostname = $aClient[$Index][4] ; Hash variablen names to prevent forbidden chars in varname Local $cCity = _Crypt_HashData($sCity, $CALG_MD5) Local $cBuilding = _Crypt_HashData($cCity & $sBuilding, $CALG_MD5) Local $cFloor = _Crypt_HashData($cBuilding & $sFloor, $CALG_MD5) Local $cZone = _Crypt_HashData($cFloor & $sZone, $CALG_MD5) if IsDeclared($cCity) Then if IsDeclared($cBuilding) Then if IsDeclared($cFloor) Then if IsDeclared($cZone) Then if not IsDeclared($sHostname) Then Assign($sHostname, _GUICtrlTreeView_AddChild($hTreeview, eval($cZone), $sHostname), $ASSIGN_FORCEGLOBAL) EndIf Else Assign($cZone, _GUICtrlTreeView_AddChild($hTreeview, eval($cFloor), $sZone), $ASSIGN_FORCEGLOBAL) Assign($sHostname, _GUICtrlTreeView_AddChild($hTreeview, eval($cZone), $sHostname), $ASSIGN_FORCEGLOBAL) EndIf Else Assign($cFloor, _GUICtrlTreeView_AddChild($hTreeview, eval($cBuilding), $sFloor), $ASSIGN_FORCEGLOBAL) Assign($cZone, _GUICtrlTreeView_AddChild($hTreeview, eval($cFloor), $sZone), $ASSIGN_FORCEGLOBAL) Assign($sHostname, _GUICtrlTreeView_AddChild($hTreeview, eval($cZone), $sHostname), $ASSIGN_FORCEGLOBAL) EndIf Else Assign($cBuilding, _GUICtrlTreeView_AddChild($hTreeview, eval($cCity), $sBuilding), $ASSIGN_FORCEGLOBAL) Assign($cFloor, _GUICtrlTreeView_AddChild($hTreeview, eval($cBuilding), $sFloor), $ASSIGN_FORCEGLOBAL) Assign($cZone, _GUICtrlTreeView_AddChild($hTreeview, eval($cFloor), $sZone), $ASSIGN_FORCEGLOBAL) Assign($sHostname, _GUICtrlTreeView_AddChild($hTreeview, eval($cZone), $sHostname), $ASSIGN_FORCEGLOBAL) EndIf Else Assign($cCity, _GUICtrlTreeView_Add($hTreeview, 0, $sCity), $ASSIGN_FORCEGLOBAL) Assign($cBuilding, _GUICtrlTreeView_AddChild($hTreeview, eval($cCity), $sBuilding), $ASSIGN_FORCEGLOBAL) Assign($cFloor, _GUICtrlTreeView_AddChild($hTreeview, eval($cBuilding), $sFloor), $ASSIGN_FORCEGLOBAL) Assign($cZone, _GUICtrlTreeView_AddChild($hTreeview, eval($cFloor), $sZone), $ASSIGN_FORCEGLOBAL) Assign($sHostname, _GUICtrlTreeView_AddChild($hTreeview, eval($cZone), $sHostname), $ASSIGN_FORCEGLOBAL) EndIf EndFunc