Jump to content
Sign in to follow this  
faustf

listview add item and subitem questions

Recommended Posts

faustf

hi guys 

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    ; Create GUI
    GUICreate("ListView Add SubItem", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($idListview, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($idListview, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 1, 2)
    ;_GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    ;_GUICtrlListView_AddSubItem($idListview, 0, "Row 2: Col 2", 1, 2)
    ;_GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

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

why if  i  run this script i see  only  row 1: col1 and  row 1 col 3  ???   i think in this mode  i should  see  row 1 col1  row 1 col 2 and  row 1 col 3  under the row1 col2

 

Share this post


Link to post
Share on other sites
VeryGary

I think you want...

_GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
Quote

#include <GuiListView.au3>
_GUICtrlListView_AddSubItem ( $hWnd, $iIndex, $sText, $iSubItem [, $iImage = -1] )

Parameters

$hWnd Control ID/Handle to the control
$iIndex 0-based index of the item
$sText Item or subitem text
$iSubItem 1-based index of the subitem
$iImage [optional] 0-based index of the icon in the control's image list

If you want "Row 1: Col 3" to appear in Row 2, Col 2 you have to create an item for row 2 and add it as a subitem for that item. 

  • _GUICtrlListView_AddItem() creates the row and first item in the row.
  • _GUICtrlListView_AddSubItem() creates additional subitems in the row.

Items and subitems are oriented left to right, not top to bottom.

Edited by VeryGary
  • Like 1

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  

×