Sign in to follow this  
Followers 0
oren

Another GUICtrlCreateTreeView $TVS_CHECKBOXES

1 post in this topic

i want to do a tree with childrens, and i want 2 things, i want that if one of the childrends will be clicket the father will be clicket and i want that it will be possible that only one children will be checket , like if there are 4 fathers and each one has 4 childrens, and if children 1-3 is checket and you click on 1-4 then it will make children 1-3 unchecket and will make 1-4 checket,

Well the only idea i'm able to think about is with a supervision array, but it will be very time consuming to build , do you have another option?

This is what i have till now without using a supervision array.

#include <TreeviewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiTreeView.au3>
#include <GUIConstantsEx.au3>

Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

GUICreate("Boxs",200,200)
GUISetState(@SW_SHOW)
$hTreeView = GUICtrlCreateTreeView(2, 2, 150, 150, $iStyle, $WS_EX_CLIENTEDGE)

_GUICtrlTreeView_BeginUpdate($hTreeView)
    $i=5

                Dim $l = $i-1
                Dim $Name[$i]
                Dim $rum[$l+1][5]
                Dim $AllChecked = 0
                $Name[0]="sss"
                $Name[1]="www"
                $q=1
                $r=1
                Dim $z = 0
                Dim $falser
                For $i = 0 to $l Step 1 
                ConsoleWrite($i & "****")
                $rum[$i][0]=_GUICtrlTreeView_AddChild($hTreeView,0, "main"&$i)
                for $r=1 to 4 Step 1 
                $rum[$i][$r]=_GUICtrlTreeView_AddChild($hTreeView, $rum[$i][0], "Sub"&$i)
                Next
                Next
                _GUICtrlTreeView_EndUpdate($hTreeView)
$AddToList=GUICtrlCreateButton("add",10,170)
 
 while 1
     for $i=0 to $l Step 1
          if False = _GUICtrlTreeView_GetChecked($hTreeView, $rum[$i][0]) Then
              for $t=1 to _GUICtrlTreeView_GetChildCount($hTreeView,$rum[$i][0]) Step 1
                  if True = _GUICtrlTreeView_GetChecked($hTreeView, $rum[$i][$t]) Then
                      _GUICtrlTreeView_SetChecked($hTreeView,$rum[$i][0],true)
                      ExitLoop
                  EndIf
              Next
          EndIf
      Next
      
  

       for $i=0 to $l Step 1
          if True = _GUICtrlTreeView_GetChecked($hTreeView, $rum[$i][0]) Then
              for $t=1 to _GUICtrlTreeView_GetChildCount($hTreeView,$rum[$i][0]) Step 1
                  if True = _GUICtrlTreeView_GetChecked($hTreeView, $rum[$i][$t]) Then 
                      For $w=$t+1 to _GUICtrlTreeView_GetChildCount($hTreeView,$rum[$i][0]) Step 1
                          _GUICtrlTreeView_SetChecked($hTreeView,$rum[$i][$w],False)
                      Next
                      ExitLoop
                      EndIf
                if $t = _GUICtrlTreeView_GetChildCount($hTreeView,$rum[$i][0]) Then _GUICtrlTreeView_SetChecked($hTreeView,$rum[$i][0],False)
              Next
          EndIf
      Next
            
     
     $exit=GUIGetMsg()
     if $exit = $GUI_EVENT_CLOSE Then Exit
         

WEnd

But its really buggy

Any Idea?

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