Jump to content

Another treeview question - making only some items have checkboxes


J3anyus
 Share

Recommended Posts

I'm trying to create a treeview of parent and child objects, where only the child objects have checkboxes next to them. However, it seems like whether or not there are checkboxes is defined for the entire treeview with $TVS_CHECKBOXES, and I don't see any way to define it per-item. Here's what I have so far to create a basic treeview where everything has checkboxes and the parent items have a slightly different GUI style:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>

Local $mainTree, $treeitem2, $treesubitem1, $treesubitem2, $treesubitem3, $treesubitem4, $guiMsg
Local $mainTreeStyle = BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_CHECKBOXES)
Local $parentItemStyle = BitOR($GUI_EXPAND, $GUI_DEFBUTTON)

GUICreate("Treeview With Children", 400, 300)

$mainTree = GUICtrlCreateTreeView(2, 2, 396, 268, $mainTreeStyle, $WS_EX_CLIENTEDGE)

$treeitem1 = GUICtrlCreateTreeViewItem("Parent Item 1", $mainTree)
$treesubitem1 = GUICtrlCreateTreeViewItem("Child Item 1", $treeitem1)
$treesubitem2 = GUICtrlCreateTreeViewItem("Child Item 2", $treeitem1)
$treeitem2 = GUICtrlCreateTreeViewItem("Parent Item 2", $mainTree)
$treesubitem3 = GUICtrlCreateTreeViewItem("Child Item 1", $treeitem2)
$treesubitem4 = GUICtrlCreateTreeViewItem("Child Item 2", $treeitem2)

GUICtrlSetState($treeitem1, $parentItemStyle)
GUICtrlSetState($treeitem2, $parentItemStyle)

GUISetState()

Do
    $guiMsg = GUIGetMsg()
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

Is there a way to make it so the parent items don't have checkboxes but the child items do?

Thanks so much ^_^

Link to comment
Share on other sites

  • 6 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...