Jump to content

Hi, I need help with GUICtrlListView


cagiva
 Share

Recommended Posts

Hi guys,

I'm looking for some help.

I want to create something like database, using _GUICtrlListView_AddItem etc.etc.

I've created a simple table with colums and rows but dont have any idea how to make all fields editable from GUI; for example row. 4 column 1 edit to any text. That means: User is double clicking somewhere in that table and he is able to change record.

I was analyzing _GUICtrlListView_EditLabel in AutoIt Help but i dont know how to use that properly. I got some problems with it.

And the second thing: i wanna copy the text from these fields (fe. edited: Row 5: Col 3 --> Good Morning!) and save it with IniWrite command to the .ini file. Is it possible? :D

Here's my code:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>

Opt('MustDeclareVars', 1)

$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

    
    GUICreate("ListView Add SubItem", 400, 300)
    $hListView = GUICtrlCreateListView("", 3, 3, 394, 268, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    
    _GUICtrlListView_SetUnicodeFormat($hListView, False)
    GUISetState()
    
    $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, 1, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 3, "Column 3", 100)
    _GUICtrlListView_InsertColumn($hListView, 4, "Column 4", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 4: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 5: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 6: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 7: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 8: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 9: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 10: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 11: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 12: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 13: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView,0, "Row 1: Col 2",1,0)
    _GUICtrlListView_AddSubItem($hListView,1, "Row 2: Col 2",1,0)
    _GUICtrlListView_AddSubItem($hListView,2, "Row 3: Col 2",1,0)
    _GUICtrlListView_AddSubItem($hListView,3, "Row 4: Col 2",1,0)
    _GUICtrlListView_AddSubItem($hListView,4, "Row 5: Col 2",1,0)
    _GUICtrlListView_AddSubItem($hListView,5, "Row 6: Col 2",1,0)
    _GUICtrlListView_AddSubItem($hListView,0, "Row 1: Col 3",2,2)
    _GUICtrlListView_AddSubItem($hListView,1, "Row 2: Col 3",2,2)
    _GUICtrlListView_AddSubItem($hListView,2, "Row 3: Col 3",2,2)
    _GUICtrlListView_AddSubItem($hListView,3, "Row 4: Col 3",2,2)
    _GUICtrlListView_AddSubItem($hListView,4, "Row 5: Col 3",2,2)
    _GUICtrlListView_AddSubItem($hListView,5, "Row 6: Col 3",2,2)
    _GUICtrlListView_AddSubItem($hListView,6, "Row 7: Col 3",2,2)
    _GUICtrlListView_AddSubItem($hListView,7, "Row 8: Col 3",2,2)
    _GUICtrlListView_AddSubItem($hListView,0, "Row 1: Col 4",3,2)
    _GUICtrlListView_AddSubItem($hListView,1, "Row 2: Col 4",3,2)
    _GUICtrlListView_AddSubItem($hListView,2, "Row 3: Col 4",3,2)
    _GUICtrlListView_AddSubItem($hListView,3, "Row 4: Col 4",3,2)
    _GUICtrlListView_AddSubItem($hListView,4, "Row 5: Col 4",3,2)
    _GUICtrlListView_AddSubItem($hListView,5, "Row 6: Col 4",3,2)
    _GUICtrlListView_AddSubItem($hListView,6, "Row 7: Col 4",3,2)
    _GUICtrlListView_AddSubItem($hListView,7, "Row 8: Col 4",3,2)
    _GUICtrlListView_AddSubItem($hListView,8, "Row 9: Col 4",3,2)
    
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc

ISO help :huggles:

TIA

Link to comment
Share on other sites

What you need to do is detect double clicks on an item in the list view. The help file example for _GUICtrlListView_EditLabel shows that you can do that with WM_NOTIFY. Then, when detected, you call _GUICtrlListView_EditLabel with the handle to the control and the index of the item that was double clicked as parameters.

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...