bourny

help with firing functions when data is changed in a GUI list view

46 posts in this topic

I am currently working on a project which simply allows me to import a csv into a gui list view.  So far I have done the following but hitting a brick wall

 - Built simple GUI with listview working

- CSV correctly importing into listview

- Able to change data in the list view and it remains the same when it is re-sorted etc. 

 

My issue comes when I am looking to carry out functions when the list view has been changed.  for Example lets say I select a cell in the list view and I change its contents.  How do I detect that change and more importantly how do I start doing things in a separate function when the change has been triggered.

My program is modelled around the same functionality provided in Melba23`s UDFs.  I am using example 3 for my tests  (https://www.autoitscript.com/forum/topic/124980-guilistviewex-new-version-10-jul-15/)

 

So in summary here is what I am struggling with.

- I change data in a cell .  How do I detect this has changed so I can do some useful stuff behind the scenes such as create a function to output the new resultant array to a text file.  (I dont need help outputting the array simply how to detect a change to a cell and how to trigger a function)

- Cannot get my head around if i am stuck in a while loop to keep the GUI alive how do I continue my script to carry out other functions.  So far I am deducing I cannot and I have to use triggers or GUIRegisterMsg functions which I have no clue about to keep the script doing what I need.  Clearly I will only need to do stuff if things happen in the GUI so I have started to think differently for GUI as I am used to traditional scripting without GUI`s locking you in a loop  (Can you tell I am new to GUI`s)

One of the main reasons I need to detect changes and make stuff happen in the background is this gui will be used by a team of people all contributing to the same listview.  Each time someone changes an entry the others will all receive that change. 

Clearly all credit to Melba32 on the listview functions. 

Any help appreciated.

 

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

Global $iCount_Left = 1, $iCount_Right = 1, $vData, $aRet, $iEditMode = 23

; Create GUI
$hGUI = GUICreate("LVEx Example 3", 640, 430)

; Create Left ListView
GUICtrlCreateLabel("Native ListView" & @CRLF & "Single sel - existing empty rows - count element - editable (all)", 10, 5, 300, 35)
$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SINGLESEL)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)
_GUICtrlListView_SetInsertMarkColor($cListView_Left, 0)

; Fill ListView with empty items
For $i = 1 To 20
    GUICtrlCreateListViewItem("||", $cListView_Left)
Next
; Create array
$aLV_List_Left = _GUIListViewEx_ReadToArray($cListView_Left, 1) ; Note count element

; Initiate GLVEx - no array passed - count parameter set - default insert mark colour (black) - drag image - editable - all columns editable (default)
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 1, 0, True, 2)

; Create Right ListView
GUICtrlCreateLabel("UDF ListView" & @CRLF & "Single selection - no count - no sort or edit", 430, 5, 300, 35)
$hListView_Right = _GUICtrlListView_Create($hGUI, "Peter", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hListView_Right, 0, 179)
_GUICtrlListView_SetInsertMarkColor($hListView_Right, 0)

; Initiate GLVEx - no array passed - no count parameter - default insert mark colour (black) - no drag image - not editable or sortable
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right)

; Create Edit Mode Combos
GUICtrlCreateLabel("Edit Modes", 330, 50, 60, 20)
GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 330, 70, 10, 80)
GUICtrlCreateLabel(":  Single Edit" & @CRLF & ":  Exit Edge" & @CRLF & ":  Stay Edge" & @CRLF & ":  Loop Edge", 340, 70, 65, 80)
GUICtrlCreateLabel("Row Mode", 330, 140, 60, 20)
$cCombo_Row = GUICtrlCreateCombo("", 330, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Row, "0|1|2|3", 2)
GUICtrlCreateLabel("Col Mode", 330, 200, 60, 20)
$cCombo_Col = GUICtrlCreateCombo("", 330, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Col, "0|1|2|3", 3)
GUICtrlCreateLabel("ESC Mode", 330, 260, 75, 20)
$cCombo_Reset = GUICtrlCreateCombo("", 330, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit")

; Create buttons
$cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30)
$cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30)
$cUp_Button = GUICtrlCreateButton("Move Up", 220, 350, 200, 30)
$cDown_Button = GUICtrlCreateButton("Move Down", 220, 390, 200, 30)
$cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30)
$cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 30)

GUISetState()

; Register for editing 7 dragging
_GUIListViewEx_MsgRegister()

; Set neither ListView as active
_GUIListViewEx_SetActive(0)

Switch _GUIListViewEx_GetActive()
    Case 0
        $sMsg = "No ListView is active"
    Case 1
        $sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------"
    Case 2
        $sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->"
EndSwitch
MsgBox(0, "Active ListView", $sMsg)

MsgBox(0, "Info", "The Left ListView has 20 empty rows" & @CRLF & "each of 3 cells which can be edited" & @CRLF & "<--------------------------")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit
        Case $cInsert_Button
            ; Prepare data  for insertion
            Switch $aGLVEx_Data[0][1]
                Case 1
                    ; Array format with multi-column native ListView
                    Global $vData[3] = ["Tom " & $iCount_Left, "Dick " & $iCount_Left, "Harry " & $iCount_Left]
                    $iCount_Left += 1
                    _GUIListViewEx_Insert($vData)
                Case 2
                    ; Array format with single-column UDF ListView
                    Global $vData[1] = ["Peter " & $iCount_Right]
                    $iCount_Right += 1
                    _GUIListViewEx_Insert($vData)
            EndSwitch

        Case $cDelete_Button
            _GUIListViewEx_Delete()

        Case $cUp_Button
            _GUIListViewEx_Up()

        Case $cDown_Button
            _GUIListViewEx_Down()

        Case $cDisplay_Left_Button
            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left")
            Else
                MsgBox(0, "Left", "Empty Array")
            EndIf

        Case $cDisplay_Right_Button
            $aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Right, "Returned Right")
            Else
                MsgBox(0, "Right", "Empty Array")
            EndIf

        Case $cCombo_Row
            Switch GUICtrlRead($cCombo_Row)
                Case 0
                    GUICtrlSetData($cCombo_Col, 0)
                Case Else
                    If GUICtrlRead($cCombo_Col) = 0 Then
                        GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Col
            Switch GUICtrlRead($cCombo_Col)
                Case 0
                    GUICtrlSetData($cCombo_Row, 0)
                Case Else
                    If GUICtrlRead($cCombo_Row) = 0 Then
                        GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Reset
            ; Toggle edit mode value to switch ESC modes
            $iEditMode *= -1

    EndSwitch

    $aRet = _GUIListViewEx_EditOnClick($iEditMode)
    ; Array only returned AFTER EditOnClick process - so check array exists
    If IsArray($aRet) Then
        ; Uncomment to see returned array
        ;_ArrayDisplay($aRet, @error)
    EndIf


WEnd

 

Share this post


Link to post
Share on other sites



Look into GUIListViewEx.au3 search for "Abandon editing" with out quotes. When you finish of editing a cell your code will be enter there. so do something for example:

$iKey_Code = 0x01 ; Abandon editing
MsgBox(0,"Edit Finish",GUICtrlRead($cGLVEx_EditID));Will show you new data inserted

Saludos

Share this post


Link to post
Share on other sites

 

DanyfirexThanks for taking the time to assist me.   I get the point to an extent where you are directing me to the abundance of code already written into Melba32`s internal functions.  I have tried adding in the msgbox just below the line with "Abandon Editing" and it does what you said pop up a msgbox to state what i have changed.  what it still does not tell me is how I capture that change and then call a different function in my script.

 

I don`t really want to make additions to the GUIListViewEx.au3 UDF to achieve my goals.  I can see that from the code the $ikey_code variable is set however I am still stuck with my original questions

 

So in summary here is what I am struggling with.

- I change data in a cell .  How do I detect this has changed so I can do some useful stuff behind the scenes such as create a function to output the new resultant array to a text file.  (I don't need help outputting the array simply how to detect a change to a cell and how to trigger a function)

- Cannot get my head around if i am stuck in a while loop to keep the GUI alive how do I continue my script to carry out other functions.  So far I am deducing I cannot and I have to use triggers or GUIRegisterMsg functions which I have no clue about to keep the script doing what I need.  Clearly I will only need to do stuff if things happen in the GUI so I have started to think differently for GUI as I am used to traditional scripting without GUI`s locking you in a loop  (Can you tell I am new to GUI`s)

One of the main reasons I need to detect changes and make stuff happen in the background is this gui will be used by a team of people all contributing to the same listview.  Each time someone changes an entry the others will all receive that change. 

Share this post


Link to post
Share on other sites

I see. so. do something with WS_WM_COMMAND. Like this. (look into debug console).

 

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include "GUIListViewEx.au3"

Global $iCount_Left = 1, $iCount_Right = 1, $vData, $aRet, $iEditMode = 23

; Create GUI
$hGUI = GUICreate("LVEx Example 3", 640, 430)

; Create Left ListView
GUICtrlCreateLabel("Native ListView" & @CRLF & "Single sel - existing empty rows - count element - editable (all)", 10, 5, 300, 35)
$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SINGLESEL)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)
_GUICtrlListView_SetInsertMarkColor($cListView_Left, 0)

; Fill ListView with empty items
For $i = 1 To 20
    GUICtrlCreateListViewItem("||", $cListView_Left)
Next
; Create array
$aLV_List_Left = _GUIListViewEx_ReadToArray($cListView_Left, 1) ; Note count element

; Initiate GLVEx - no array passed - count parameter set - default insert mark colour (black) - drag image - editable - all columns editable (default)
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 1, 0, True, 2)

; Create Right ListView
GUICtrlCreateLabel("UDF ListView" & @CRLF & "Single selection - no count - no sort or edit", 430, 5, 300, 35)
$hListView_Right = _GUICtrlListView_Create($hGUI, "Peter", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hListView_Right, 0, 179)
_GUICtrlListView_SetInsertMarkColor($hListView_Right, 0)

; Initiate GLVEx - no array passed - no count parameter - default insert mark colour (black) - no drag image - not editable or sortable
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right)

; Create Edit Mode Combos
GUICtrlCreateLabel("Edit Modes", 330, 50, 60, 20)
GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 330, 70, 10, 80)
GUICtrlCreateLabel(":  Single Edit" & @CRLF & ":  Exit Edge" & @CRLF & ":  Stay Edge" & @CRLF & ":  Loop Edge", 340, 70, 65, 80)
GUICtrlCreateLabel("Row Mode", 330, 140, 60, 20)
$cCombo_Row = GUICtrlCreateCombo("", 330, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Row, "0|1|2|3", 2)
GUICtrlCreateLabel("Col Mode", 330, 200, 60, 20)
$cCombo_Col = GUICtrlCreateCombo("", 330, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Col, "0|1|2|3", 3)
GUICtrlCreateLabel("ESC Mode", 330, 260, 75, 20)
$cCombo_Reset = GUICtrlCreateCombo("", 330, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit")

; Create buttons
$cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30)
$cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30)
$cUp_Button = GUICtrlCreateButton("Move Up", 220, 350, 200, 30)
$cDown_Button = GUICtrlCreateButton("Move Down", 220, 390, 200, 30)
$cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30)
$cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 30)

GUISetState()

; Register for editing 7 dragging
_GUIListViewEx_MsgRegister()
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
; Set neither ListView as active
_GUIListViewEx_SetActive(0)

Switch _GUIListViewEx_GetActive()
    Case 0
        $sMsg = "No ListView is active"
    Case 1
        $sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------"
    Case 2
        $sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->"
EndSwitch
MsgBox(0, "Active ListView", $sMsg)

MsgBox(0, "Info", "The Left ListView has 20 empty rows" & @CRLF & "each of 3 cells which can be edited" & @CRLF & "<--------------------------")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit
        Case $cInsert_Button
            ; Prepare data  for insertion
            Switch $aGLVEx_Data[0][1]
                Case 1
                    ; Array format with multi-column native ListView
                    Global $vData[3] = ["Tom " & $iCount_Left, "Dick " & $iCount_Left, "Harry " & $iCount_Left]
                    $iCount_Left += 1
                    _GUIListViewEx_Insert($vData)
                Case 2
                    ; Array format with single-column UDF ListView
                    Global $vData[1] = ["Peter " & $iCount_Right]
                    $iCount_Right += 1
                    _GUIListViewEx_Insert($vData)
            EndSwitch

        Case $cDelete_Button
            _GUIListViewEx_Delete()

        Case $cUp_Button
            _GUIListViewEx_Up()

        Case $cDown_Button
            _GUIListViewEx_Down()

        Case $cDisplay_Left_Button
            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left")
            Else
                MsgBox(0, "Left", "Empty Array")
            EndIf

        Case $cDisplay_Right_Button
            $aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Right, "Returned Right")
            Else
                MsgBox(0, "Right", "Empty Array")
            EndIf

        Case $cCombo_Row
            Switch GUICtrlRead($cCombo_Row)
                Case 0
                    GUICtrlSetData($cCombo_Col, 0)
                Case Else
                    If GUICtrlRead($cCombo_Col) = 0 Then
                        GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Col
            Switch GUICtrlRead($cCombo_Col)
                Case 0
                    GUICtrlSetData($cCombo_Row, 0)
                Case Else
                    If GUICtrlRead($cCombo_Row) = 0 Then
                        GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Reset
            ; Toggle edit mode value to switch ESC modes
            $iEditMode *= -1

    EndSwitch

    $aRet = _GUIListViewEx_EditOnClick($iEditMode)
    ; Array only returned AFTER EditOnClick process - so check array exists
    If IsArray($aRet) Then
        ; Uncomment to see returned array
        ;_ArrayDisplay($aRet, @error)
    EndIf


WEnd

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
    $hWndFrom = $ilParam
    $iIDFrom = _WinAPI_LoWord($iwParam)
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $iIDFrom
        Case $cGLVEx_EditID
            If $iCode = $EN_KILLFOCUS Then ; Sent when an edit control loses the keyboard focus
                ConsoleWrite(GUICtrlRead($iIDFrom) & @CRLF)
                ;Do Something
            EndIf

    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Saludos

Share this post


Link to post
Share on other sites

Perfect.  

That does exactly what I need.  I had to comment out the line in my core script that actually uses combo boxes instead of free type edit.  With the combo boxes in place the capture does not happen and I understand it is because I am looking for an exact handle match for editing not using a drop down.  I have no clue how to get the same to happen if I do other things and make other changes that are not just editing handles by your example.  

this leaves me with the following questions.

1. what is the best source of information to help me understand what is being done here with the GUIRegisterMsg options.  Clearly its out of my knowledge but with the correct pointers I will be able to get a grasp of how I capture and use behaviours and events happening in a GUI.  I have read the help files but still struggling to get a grasp of the concept.

2.  Still unsure about being stuck in this while loop on the GUI.  Is this normal and would I always use  GUIRegisterMsg to handle user functions with GUI`s.  Not the normal scripts of passing between functions and loops pretty much stopping your script if it was not an adlib function.

 

Share this post


Link to post
Share on other sites

bourny,

No need for you to hook into the "Internal Use Only" functions - they are just that and you should not play around with them.

As explained in the function headers, all you need to do is check for the return value from the _GUIListViewEx_EditOnClick function. If it is an array then a ListView item/subitem was edited and the array tells you how many, which ones and what was changed - this example shows how to do it.:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <GUIListViewEx.au3>

Global $aArray[10]

$hGUI = GUICreate("Test", 500, 500)

$cLV = GUICtrlCreateListView("Double click to edit", 10, 10, 400, 200)
For $i = 0 To 9
    $aArray[$i] = "Item " & $i

    GUICtrlCreateListViewItem("Item " & $i, $cLV)
Next

GUISetState()

_GUIListViewEx_Init($cLV, $aArray, 0, 0, False, 2, "0")

_GUIListViewEx_MsgRegister()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch



    $aEdited = _GUIListViewEx_EditOnClick()
    If IsArray($aEdited) Then
        _ArrayDisplay($aEdited, "Edited cells", Default, 8)
    EndIf

WEnd

All clear?

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Yes.  That works for everything now.  Combo box changes or free editing.  That is great.  So in summary I do not need to understand or use the GUIRegisterMsg functions just use your already coded functions.  (would still like to understand more about GUIRegisterMsg if you can provide any good study links)

 

I have a few more questions and would be very appreciative if you could assist as you wrote this udf that I am using.  (Happy to put this in a new topic if you require)

I am using your listview as the core of my program.  The program will have multiple users all contributing towards filling in the data in the listview (imported from a csv).  I notice when I make changes a hidden array controlling the data is also updated (Saves me a lot of pain).  My plan is to make use of this array to publish its contents to other users and merge any entries that have changed from other users so everyone keeps up to date with changes each person is making.  this is the reason i needed to trigger a function on changing values to allow me to do some stuff behind the scenes to publish this updated array to others and merge in other users changes.

 

Clearly I will need to output the contents of the array to a share that all the users can see and the program simply needs to keep pulling this in and exporting it out with some update versions attached to the exports to ensure all users do not lose any entered data.

 

Thanks for your help so far.  Well on the road now to getting this program off the ground.

Share this post


Link to post
Share on other sites

bourny,

would still like to understand more about GUIRegisterMsg if you can provide any good study links

I would start with the GUIRegisterMsg tutorial in the Wiki - that should give you a good overview.

I notice when I make changes a hidden array controlling the data is also updated

That is exactly what happens - and you can access that array at any time via the _GUIListViewEx_ReturnArray function. However, your idea of trying to have several users simultaneously working on the ListView sounds fraught with danger - if you actually pull it off, I will be very interested to see how you manage it. I would suggest reloading the modified array into the ListView using the _GUIListViewEx_Insert function after having deleted the current content with _GUIListViewEx_Delete - that way the internal array will be automatically updated.

Do not hesitate to ask if I can be of assistance with the current UDF code, or if you feel that any new features could be added to the UDF to simplify your task - no guarantee that they will be, of course, but no harm in asking!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Thanks again.

 

I understand the  scale of what I am trying to achieve with all the problems and risks but I believe is defiantly achievable.  Normally databases would be used and SQL code but despite having a good knowledge of TSQL I do not want to take this program in that direction for a few reasons.  The fact your UDF can already handle the updating of the internal array puts me miles ahead of where I would have been starting.

No doubt you will see posts from me while I overcome some of the challenges of this project however I will as you have asked update you with how I pull this off using your code as the heart of the engine.

Thanks for all your assistance and for the UDF.

Share this post


Link to post
Share on other sites

Ran into an issue with the combo drop down list.  I have created a file with around 40 entries that gets imported into the listview.  The list imports as expected but has the following issues - 

1. The width of the combo box drop down is too small.  I could fix this by adding code to simply test the imported data for the longest string and adjust the column width by that amount.  is there a better way to do this in the _GUIListViewEx UDF as i cannot find it anywhere.

2.  I have added separators into the list view to allow it to be read easily.  Clearly the separators can be selected as the combo has no clue I intend to use it as a separator and not a choice.  how do I stop the separators form being a selectable item

3. The height of the combo drop down is too short and cuts of the majority of the information

One of the options I am considering if I cannot fix this is to present a pop up combo box on the GUI and what ever data is selected is somehow then re in-putted into the Listview at the correct place.  I don't like the idea of a popup and it introduces issues trying to ensure the data is captured and passed back corrrectly.  Having it inline is much better.

I would like to avoid writing adhoc code into the _GUIListViewEx UDF and preferably keep within the bounds of fixing this issue by means of using the _GUIListViewEx UDF if possible.

any suggestions appreciatedcomboIssue.thumb.JPG.e0e9ace3c110ad19dd5

Share this post


Link to post
Share on other sites

bourny,

The combo width and styles are set by the UDF when the combo is created - I will look at how they might be adjusted to cater for your voluminous data requirements.

As to the separators, I do know how to create a combo with non-selectable separators, but it involves a user-drawn combo control which involves some quite complex code. As a result, I am loath to add it to the UDF as the script is already complex enough and the edit combo is only a minor part of its functionality. However, as I showed in post #6 above, you get a notification of changes made and so you can easily verify if a separator was selected and reset the previous value using the _GUIListViewEx_ChangeItem function. This functionality was added to the UDF in the 7 Jan 15 release specifically to cater for possible invalid edits:

[NEW VERSION] - 7 Jan 15
------------------------

Added: New function (_GUIListViewEx_ChangeItem) to allow ListView items to be changed programmatically.

Changed:

    - [..]

    - Return arrays after item or header edit now contain both original and new content to allow for checking and possible replacement (using the new function)

I will try to produce a Beta UDF version and some example code for you - but do not hold your breath as I have to travel quite a distance and attend my god-daughter's wedding this weekend and my better half would frown if I took a lap-top into the church!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Melba23,  Appreciate your continued input and I am more than happy to use the Reset function on detection of my invalid characters.  That will provide exactly what I need.

 

I am happy to wait for, and test any amendments you make to your UDF in order to assist me as you are not obligated in any way.  I have enough to crack on with building the rest of the program so this will just ignore the formatting issue as It is a simple cosmetic annoyance to myself.  Clearly I will need to resolve before the users go live with it but that will not be for a couple of weeks yet.  Very grateful for the time you are spending on this for me and enjoy the wedding.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

bourny,

A quiet day before departing for the weekend meant I could look at the UDF and I was pleasantly surprised to see that it was not a difficult job to modify it - just an additional parameter in the _GUIListViewEx_ComboData function to define the width of the combo dropdown. It means you have to do some work in the script to determine just how wide that should be - but another of my UDFS (StringSize - link in my sig) will do that for you.

So here is a Beta version of the UDF and an example script to show it working (look for the <<< lines):  GUIListViewEx_Mod.zip

Let me know if it meets your requirements - and comments from anyone else welcome too.

M23

 

 

Edited by Melba23
Beta code removed

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Excellent Thanks M23.  Will test and come back to you.

Share this post


Link to post
Share on other sites

Melba23,

Tested the changes and the drop down scroll bar works perfectly.  I have also managed to incorporate your stringsize UDF with some extra code to find out what is the longest bit of txt in my selection list.  When I apply this value to _GUIListViewEx_ComboData function the length of the combo box does not get any longer and remains bound by the width of the column the combo box belongs to.  I tried simply then redeclaring _GUICtrlListView_SetColumnWidth to the size of the longest bit of text and it worked but now the column is so wide it is off screen.

So this is where I am at now. : Can I keep the column width reasonably small as the column header is simply "RESULT", yet have the drop down combo boxes exceed the size of the column width.  

Share this post


Link to post
Share on other sites

bourny,

That makes it cound as if you want the edit portion of the combo to be as wide as the dropdown section - which would not be difficult to do. But I fail to see the overall utility. If you do not increase the actual column width then the selected value will be truncated when displayed, regardless of the increased combo width during selection.  So why have a wider combo edit - surely having a wider dropdown so that the selectable combo elements are suitably visible is all that is necessary?

Perhaps having the selected item displayed in a tooltip might be a better solution than widening the column - let me see what I can do.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

I have lets say 10 columns and would not like to afford too much real estate in my GUI to the column containing this drop down combo box.  I want to keep the column size restricted yet still allow for the options when selected to be fully visible.  I think I am now exceeding the bounds of what I am trying to achieve. I may need to go down the route of a pop up box or something that can be used for the selection.

 

 

Share this post


Link to post
Share on other sites

bourny,

You can use the combobox code I posted above for the selection as it displays the full width of the options.  If you want to see the complete selected value when only a truncated version is displayed in a narrow ListView column then my suggeston of a tooltip should be adequate. As I said above - let me see what I can do.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

bourny,

Try this Beta code - I have added a couple of functions to help you. _GUIListViewEx_ToolTipInit allows you to define columns which will display a tooltip when clicked so that long items can be visible even if the column is too narrow - _GUIListViewEx_ToolTipShow is run in the idle loop to display them:

M23

Edit: It appears the forum is not letting me upload files at the moment - I will try again later.

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Thanks M23.  Will take a look once once it is uploaded.

 

 

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