Jump to content

_GUIListViewEx Editable Single Column List


Recommended Posts

So I thought this should've been easy (because Melba23 did so much work). I just want to be able to add an editable list view with a single column to my GUI. This is a simplified version of what I have so far... (no really, it is, mostly it's building the GUI)

#include <GUIConstants.au3>
#include <GuiListViewEx.au3>

Global $hGUI, $hCategoriesListView, $hDelBttn, $hReloadBttn, $hAddBttn, $hSaveBttn

Main()

Func Main()

    #Region ### GUI Creation ###

    Local Const $iCONTROL_HEIGHT = 20, $iGUI_V_SPACING = 5, $iGUI_H_SPACING = 5

    $hGUI = GUICreate("Outlook Categories", 500, 320)

    Local $iRow = $iGUI_V_SPACING
    GUICtrlCreateLabel("Categories", $iGUI_H_SPACING, $iRow, 50, $iCONTROL_HEIGHT)

    $iRow += $iGUI_V_SPACING + $iCONTROL_HEIGHT
    $hCategoriesListView = GUICtrlCreateListView("Categories", $iGUI_H_SPACING, $iRow, 490, 250, $LVS_LIST + $LVS_SHOWSELALWAYS)
    _GUICtrlListView_SetExtendedListViewStyle($hCategoriesListView, $LVS_EX_DOUBLEBUFFER + $LVS_EX_FLATSB)
;~  $hCategoriesListView = GUICtrlCreateListView("Categories", $iGUI_H_SPACING, $iRow, 490, 250, $LVS_LIST + $LVS_EDITLABELS + $LVS_NOCOLUMNHEADER + $LVS_NOLABELWRAP, $LVS_EX_DOUBLEBUFFER + $LVS_EX_FLATSB)

    $iRow += $iGUI_V_SPACING + 250
    $hDelBttn = GUICtrlCreateButton("Delete", $iGUI_H_SPACING, $iRow, 50, $iCONTROL_HEIGHT)
    $hAddBttn = GUICtrlCreateButton("Add", 2 * $iGUI_H_SPACING + 50, $iRow, 50, $iCONTROL_HEIGHT)
    $hReloadBttn = GUICtrlCreateButton("Reload", 3 * $iGUI_H_SPACING + 100, $iRow, 50, $iCONTROL_HEIGHT)
    $hSaveBttn = GUICtrlCreateButton("Save", 4 * $iGUI_H_SPACING + 150, $iRow, 50, $iCONTROL_HEIGHT)

    GUISetState(@SW_SHOW)

    Local $iListEx = _GUIListViewEx_Init($hCategoriesListView)
    If @error Then ConsoleWrite("! Error: _GUIListViewEx_Init")

    _GUIListViewEx_SetEditStatus($iListEx, "*", 1)
    If @error Then ConsoleWrite("! Error: _GUIListViewEx_SetEditStatus")

    _GUIListViewEx_MsgRegister()
    _GUIListViewEx_SetEditKey("{F2}")
    _GUIListViewEx_SetActive(1)
    
    #EndRegion ### GUI Creation ###

    Local $vRet

    While True
        Switch GUIGetMsg()
            Case $hDelBttn
                _GUIListViewEx_Delete()
            Case $hAddBttn
                $vRet = InputBox("New Category", "What is the name?")
                _GUICtrlListView_AddItem($hCategoriesListView, $vRet)
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch

        $vRet = _GUIListViewEx_EventMonitor()
        If $vRet <> "" Or @error <> 0 Or @extended <> 0 Then ConsoleWrite("! Error: " & @error & " _GUIListViewEx_EventMonitor Extended: " & @extended & " Return: " & $vRet& @CRLF)

    WEnd

EndFunc

I'm not sure if it has something to do with the styles I'm attempting to add or if I'm missing an important function call somewhere. The code above errors out in the UDF currently when exiting the edit, but I'm guessing I missed a property or set something wrong.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Caveat, I've not read the instructions! But I do see that double clicking on some of the examples, in the same way that I have with your code to edit, produces "Event error: 3" and no editing happens, perhaps there is a small bug depending on how data is added to the list?

It seems when you are adding an entry it is not getting added to $aGLVEx_SrcArray so when you later try to edit it you get the problem.

I'm afraid I am out of time on this and have not been much help, sorry! 

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Link to comment
Share on other sites

1 hour ago, SlackerAl said:

It seems when you are adding an entry it is not getting added to $aGLVEx_SrcArray so when you later try to edit it you get the problem.

I'm afraid I am out of time on this and have not been much help, sorry! 

You're exactly right! Thank you! I needed to use _GUIListViewEx_Insert() instead of GUICtrlListView_AddItem(). It killed the errors and allows editing :D

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

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