Jump to content
Sign in to follow this  

Listview... Anyway to remove checkbox for child items?

Recommended Posts

Had a question that wasn't apparant to me...

If you have a listview with $TVS_HASBUTTONS and $TVS_CHECKBOXES turned on, is there a way to make it so that any child items do not have checkboxes?

I was hoping to have something where checkboxes could be turned on for a parent, but the child properties would have no checkbox and would just include descriptive text about the parents.


Also, is there a way to force all of the child objects to be checked when the parent is checked? After reading some threads I saw a lot of people having problems with this configuration being turned on, but mine seems to be off by default.


Thanks in advance!

Share this post

Link to post
Share on other sites

Do you mean a TreeView?

This is the example for _GUICtrlTreeView_SetStateImageIndex modified a little bit:


#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

Global $hStateImage


Func Example()
  Local $hItem[10], $hChildItem[30], $iYItem = 0, $hTreeView
  GUICreate("TreeView Set State Image Index", 400, 300)

  $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)

  ;_GUICtrlTreeView_SetStateImageList($hTreeView, $hStateImage)

  For $x = 0 To 9
    $hItem[$x] = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x))
    _GUICtrlTreeView_SetStateImageIndex($hTreeView, $hItem[$x], 1)
    For $y = 1 To 3
      $hChildItem[$iYItem] = _GUICtrlTreeView_AddChild($hTreeView, $hItem[$x], StringFormat("[%02d] New Child", $y))
      _GUICtrlTreeView_SetStateImageIndex($hTreeView, $hChildItem[$iYItem], 0)
      $iYItem += 1

  _GUICtrlTreeView_SelectItem($hTreeView, $hItem[0])
  ;_GUICtrlTreeView_SetStateImageIndex($hTreeView, $hItem[0], 2)

  MsgBox($MB_SYSTEMMODAL, "Information", "State Image Index for Item 0: " & _GUICtrlTreeView_GetStateImageIndex($hTreeView, $hItem[0]))

  ; Loop until the user exits.
  Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func _CreateStateImageList()
  $hStateImage = _GUIImageList_Create(16, 16, 5, 3)
  _GUIImageList_AddIcon($hStateImage, "shell32.dll", 3)
  _GUIImageList_AddIcon($hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...