Jump to content

My loop doesn't add any subitem ...


 Share

Recommended Posts

Hi all,

I don't understand why the column 2 and 3 have no value when i press GO button

Thx for help

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
$ListView1 = GUICtrlCreateListView("", 48, 48, 538, 382)
$Go = GUICtrlCreateButton("Go", 280, 8, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Go
go()
EndSwitch
WEnd

Func Go()

_GUICtrlListView_Destroy($ListView1)
$ListView1 = GUICtrlCreateListView("", 48, 48, 538, 382)

_GUICtrlListView_InsertColumn($ListView1, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($ListView1, 1, "Column 2", 100)
_GUICtrlListView_InsertColumn($ListView1, 2, "Column 3", 100)

$i = 1
For $dropcols = 1 To 100

If $i = 1 Then
_GUICtrlListView_AddItem($ListView1, $dropcols)
Else
If $i > 3 Then
$i = 0
Else
_GUICtrlListView_AddSubItem($ListView1, $i, $dropcols, $dropcols)
EndIf
EndIf
$i = $i + 1
Next

EndFunc   ;==>Go
Edited by Reekod
Link to comment
Share on other sites

  • Moderators

Reekod,

Because your parameters for the _GUICtrlListView_AddSubItem function were all wrong. This works for me: ;)

For $dropcols = 1 To 100

    If $i = 1 Then
        $iIndex = _GUICtrlListView_AddItem($ListView1, $dropcols)
    Else
        If $i > 3 Then
            $i = 0
        Else
            _GUICtrlListView_AddSubItem($ListView1, $iIndex, $dropcols, $i - 1)
        EndIf
    EndIf
    $i = $i + 1
Next

See if you can work out why this works and yours did not. Ask if you have any questions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thank you so much!

i don't knew this handle way of _GUICtrlListView_AddItem

i learn with the exemple help file :

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $hImage, $hListView
; Create GUI
GUICreate("ListView Add SubItem", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
GUISetState()
; Load images
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0xFF0000, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0x00FF00, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0x0000FF, 16, 16))
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
; Add columns
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
_GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)
; Add items
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1, 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2, 2)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1, 2)
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc   ;==>_Main

i was not able to imagine that you can handle a function like this to declare the subitem in a list view

Thank you aigain !

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

×
×
  • Create New...