Sign in to follow this  
Followers 0
super1337

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

3 posts in this topic

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

Example()

Func Example()
  Local $hItem[10], $hChildItem[30], $iYItem = 0, $hTreeView
  Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
  GUICreate("TreeView Set State Image Index", 400, 300)

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

  ;_CreateStateImageList()
  ;_GUICtrlTreeView_SetStateImageList($hTreeView, $hStateImage)

  _GUICtrlTreeView_BeginUpdate($hTreeView)
  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
    Next
  Next
  _GUICtrlTreeView_EndUpdate($hTreeView)

  _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.
  Do
  Until GUIGetMsg() = $GUI_EVENT_CLOSE
  GUIDelete()
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

Lars you're the man... that is exactly what I was looking for!

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