Jump to content

_GUICtrlListView_AddSubItem problem


d0n
 Share

Recommended Posts

I am trying to put some text in my listview, but the subitem just wont add for me, not sure why

it works if i just use GUICtrlcreatelistviewitem

Func List()
    $List = IniReadSection(@ScriptDir&"\list.ini", GUIctrlread($Combo1))
    For $i = 1 to $List[0][0]
        _GUICtrlListView_AddItem($List1, $List[$i][0])
        _GUICtrlListView_AddSubItem($List1, $i, "0", 1)
        _GUICtrlListView_AddSubItem($List1, 0, $List[$i][1], 2)
        ;GUICtrlCreateListViewItem($Skill_List[$i][0]&"|0|"&$Skill_List[$i][1], $List1)
    Next
    _GUICtrlListView_SetItemSelected($List1, 0)
EndFunc
Link to comment
Share on other sites

I am trying to put some text in my listview, but the subitem just wont add for me, not sure why

it works if i just use GUICtrlcreatelistviewitem

Func List()
    $List = IniReadSection(@ScriptDir&"\list.ini", GUIctrlread($Combo1))
    For $i = 1 to $List[0][0]
        _GUICtrlListView_AddItem($List1, $List[$i][0])
        _GUICtrlListView_AddSubItem($List1, $i, "0", 1)
        _GUICtrlListView_AddSubItem($List1, 0, $List[$i][1], 2)
        ;GUICtrlCreateListViewItem($Skill_List[$i][0]&"|0|"&$Skill_List[$i][1], $List1)
    Next
    _GUICtrlListView_SetItemSelected($List1, 0)
EndFunc

Make sure you are using a handle:

_GUICtrlListView_AddSubItem(GUICtrlGetHandle($List1), $i, "0", 1)
Link to comment
Share on other sites

I don't know then. Post your entire script so I can see if theres something else missing.

Link to comment
Share on other sites

_GUICtrlListView_AddItem($List1, $List[$i][0])

The return value is very important for subsequent call like _GUICtrlListView_AddSubItem() because it's expecting the index of the item you're referring to. In other words:

Func List()
    $List = IniReadSection(@ScriptDir&"\list.ini", GUIctrlread($Combo1))
    For $i = 1 to $List[0][0]
        $iIndex = _GUICtrlListView_AddItem($List1, $List[$i][0])
        _GUICtrlListView_AddSubItem($List1, $iIndex , "0", 1)
        _GUICtrlListView_AddSubItem($List1, $iIndex, $List[$i][1], 2)
        ;GUICtrlCreateListViewItem($Skill_List[$i][0]&"|0|"&$Skill_List[$i][1], $List1)
    Next
    _GUICtrlListView_SetItemSelected($List1, 0)
EndFunc

The code snippet example from the help file doesn't reflect that but it's required. It's documented though.

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#Include <Array.au3>
Global $SkillPoint, $List1

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 455, 454, 268, 114)

GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)


$List1 = GUICtrlCreateListView("1|3|2", 24, 104, 201, 279)
    _GUICtrlListView_SetColumnWidth(-1, 0, 90)
    _GUICtrlListView_SetColumnWidth(-1, 1, 55)
    _GUICtrlListView_SetColumnWidth(-1, 2, 45)
GUISetState(@SW_SHOW)
List()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        EndSwitch
    Sleep(10)

WEnd

Func List()
    $List = IniReadSection(@ScriptDir&"\test.ini", "test")
    For $i = 1 to $List[0][0]
        _GUICtrlListView_AddItem($List1, $List[$i][0])
        _GUICtrlListView_AddSubItem($List1, $i, "0", 1)
        _GUICtrlListView_AddSubItem($List1, $i, $List[$i][1], 2)
        ;GUICtrlCreateListViewItem($Skill_List[$i][0]&"|0|"&$Skill_List[$i][1], $List1)
    Next
    _GUICtrlListView_SetItemSelected($List1, 0)
EndFunc

The ini is just

[test]

apple=1

orange=2

banana=13

Link to comment
Share on other sites

Link to comment
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
 Share

  • Recently Browsing   0 members

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