dickep Posted February 18, 2008 Posted February 18, 2008 How can I check on item in a treeview and have it check all the other boxes in that treeview? I had MsCreatoR give me an example using a listview but I don't want any columns in the windows. Thanks E
MrCreatoR Posted February 18, 2008 Posted February 18, 2008 expandcollapse popup#include <GUIConstants.au3> Opt("GuiOnEventMode", 1) GUICreate("TreeView Check All", 460, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "MainEvents") $TreeView = GUICtrlCreateTreeView(20, 20, 420, 260, BitOr($GUI_SS_DEFAULT_TREEVIEW, $TVS_CHECKBOXES), _ $WS_EX_DLGMODALFRAME+$WS_EX_CLIENTEDGE) $SelAll_Item = GUICtrlCreateTreeViewItem("Select all", $TreeView) GUICtrlSetOnEvent(-1, "MainEvents") GUICtrlSetColor($SelAll_Item, 0xC0C0C0) Global $TVItemsID_Array[11] For $i = 1 To UBound($TVItemsID_Array)-1 $TVItemsID_Array[$i] = GUICtrlCreateTreeViewItem("Item " & $i, $SelAll_Item) GUICtrlSetOnEvent(-1, "MainEvents") Next GUICtrlSetState($SelAll_Item, $GUI_EXPAND) GUISetState() While 1 Sleep(10) WEnd Func MainEvents() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE Exit Case $SelAll_Item Local $State = $GUI_UNCHECKED If BitAND(GUICtrlRead($SelAll_Item), $GUI_CHECKED) Then $State = $GUI_CHECKED GUICtrlSetColor($SelAll_Item, 0x0) Else GUICtrlSetColor($SelAll_Item, 0xC0C0C0) EndIf For $a = 1 To UBound($TVItemsID_Array)-1 GUICtrlSetState($TVItemsID_Array[$a], $State) Next Case Else If OneIsChecked() Then If AllIsChecked() Then GUICtrlSetColor($SelAll_Item, 0x0) Else GUICtrlSetColor($SelAll_Item, 0x696969) EndIf GUICtrlSetState($SelAll_Item, $GUI_CHECKED) Else GUICtrlSetColor($SelAll_Item, 0xC0C0C0) GUICtrlSetState($SelAll_Item, $GUI_UNCHECKED) EndIf EndSwitch EndFunc Func OneIsChecked() For $i = 1 To UBound($TVItemsID_Array)-1 If BitAND(GUICtrlRead($TVItemsID_Array[$i]), $GUI_CHECKED) Then Return True Next Return False EndFunc Func AllIsChecked() For $i = 1 To UBound($TVItemsID_Array)-1 If BitAND(GUICtrlRead($TVItemsID_Array[$i]), $GUI_UNCHECKED) Then Return False Next Return True EndFunc but I don't want any columns in the windows.Check the thread again. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
enaiman Posted February 19, 2008 Posted February 19, 2008 @MsCreatoR Brilliant I had quite a similar problem with a treeview (been using A3LTreeView) - trying to check all checkboxes (alot of checkboxes to check) and it didn't work properly. I've just decided to ask for help in this forum when I saw your post Lucky me Thank you SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
MrCreatoR Posted February 20, 2008 Posted February 20, 2008 BrilliantThanks Here is an improved version, OnEvent Mode not used here: expandcollapse popup#include <GUIConstants.au3> Global $iTotal_Items = 10 Global $TVItemsID_Array[$iTotal_Items + 1] GUICreate("TreeView Check All", 460, 300) $TreeView = GUICtrlCreateTreeView(20, 20, 420, 260, _ BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_CHECKBOXES), $WS_EX_DLGMODALFRAME + $WS_EX_CLIENTEDGE) $SelAll_TVItem = GUICtrlCreateTreeViewItem("Select all", $TreeView) GUICtrlSetColor($SelAll_TVItem, 0xC0C0C0) For $i = 1 To $iTotal_Items $TVItemsID_Array[$i] = GUICtrlCreateTreeViewItem("Item " & $i, $SelAll_TVItem) Next GUICtrlSetState($SelAll_TVItem, $GUI_EXPAND) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SelAll_TVItem Local $State = $GUI_UNCHECKED If BitAND(GUICtrlRead($SelAll_TVItem), $GUI_CHECKED) Then $State = $GUI_CHECKED GUICtrlSetColor($SelAll_TVItem, 0x0) GUICtrlSetState($SelAll_TVItem, $GUI_DEFBUTTON + $GUI_CHECKED) Else GUICtrlSetColor($SelAll_TVItem, 0xC0C0C0) GUICtrlSetState($SelAll_TVItem, $GUI_UNCHECKED) EndIf For $a = 1 To UBound($TVItemsID_Array) - 1 GUICtrlSetState($TVItemsID_Array[$a], $State) Next Case $TVItemsID_Array[1] To $TVItemsID_Array[$iTotal_Items] If AllIsUnChecked() Then GUICtrlSetColor($SelAll_TVItem, 0xC0C0C0) GUICtrlSetState($SelAll_TVItem, $GUI_UNCHECKED) ElseIf AllIsChecked() Then GUICtrlSetColor($SelAll_TVItem, 0x0) GUICtrlSetState($SelAll_TVItem, $GUI_DEFBUTTON + $GUI_CHECKED) Else GUICtrlSetColor($SelAll_TVItem, 0x696969) GUICtrlSetState($SelAll_TVItem, $GUI_CHECKED) EndIf EndSwitch WEnd Func AllIsUnChecked() For $i = 1 To UBound($TVItemsID_Array) - 1 If BitAND(GUICtrlRead($TVItemsID_Array[$i]), $GUI_CHECKED) Then Return False Next Return True EndFunc Func AllIsChecked() For $i = 1 To UBound($TVItemsID_Array) - 1 If BitAND(GUICtrlRead($TVItemsID_Array[$i]), $GUI_UNCHECKED) Then Return False Next Return True EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
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