Sign in to follow this  
Followers 0
tolyasher

Creating editable ListView control with 'OnEvent' mode

7 posts in this topic

Hi guys,

I am trying to create ListView control with possibility edit it (items in it). But afterdabble click just first column of selected item become editable. Therewith double click does not work properly. Label become editable from time to time. Is it possible to edit every label ? I use 'OnEvent' mode.

I list peace of my code.

Thank you in advance!

Local $DualListDlg = GUICreate("Test-O-Matic", 921, 550, 202, 141, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetIcon("D:\007.ico")
GUISetOnEvent($GUI_EVENT_CLOSE, "DualListDlgClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "DualListDlgMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "DualListDlgMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "DualListDlgRestore")
;Local $ListView1 = GUICtrlCreateList("", 24, 32, 257, 227, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER))
Local $ListView1 = GUICtrlCreateListView("Test Number|Test Name                            |Device|Protocol|Port", 16, 32, 418, 230)
    GUICtrlSetOnEvent($ListView1, "ListView1Click")
Local $ListViewItems1[1]    
Local $GUICTRL_RIGHTARROW_BTN = GUICtrlCreateButton(">", 448, 48, 30, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_RIGHTARROW_BTN, "RightArrowClick")
Local $Button2 = GUICtrlCreateButton(">>", 448, 104, 31, 25, $WS_GROUP)
    GUICtrlSetOnEvent($Button2, "Button2Click")
Local $GUICTRL_LEFTARROW_BTN = GUICtrlCreateButton("<", 448, 152, 31, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_LEFTARROW_BTN, "LeftArrowClick")
Local $GUICTRL_DOUBLELEFTARROW_BTN = GUICtrlCreateButton("<<", 448, 208, 32, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_DOUBLELEFTARROW_BTN, "DoubleLeftArrowClick")
Local $ListView2 = GUICtrlCreateListView("Test Number|Test Name                            |Device|Protocol|Port", 488, 32, 418, 230, BitOR($LVS_EDITLABELS, $LVS_SINGLESEL, $LVS_REPORT) )
    GUICtrlSetOnEvent($ListView2, "ListView2Click")
Local $ListViewItems2[1]    
Local $GUICTRL_SAVESUIT_BTN = GUICtrlCreateButton("&Save", 688, 416, 75, 25,  $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_SAVESUIT_BTN, "SaveSuitClick")
Local $GUICTRL_EXIT_BTN = GUICtrlCreateButton("&Exit", 424, 488, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_EXIT_BTN, "ExitClick")
Local $Button7 = GUICtrlCreateButton("&Help", 424, 520, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent($Button7, "Button7Click")
Local $GUICTRL_RUNTESTSUIT__BTN = GUICtrlCreateButton("Run", 424, 424, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_RUNTESTSUIT__BTN, "RunSuitClick")
Local $GUICTRL_CONTINUE__BTN = GUICtrlCreateButton("&Continue", 424, 456, 75, 25, $WS_GROUP)
    GUICtrlSetState($GUICTRL_CONTINUE__BTN, $GUI_DISABLE)
    GUICtrlSetOnEvent($GUICTRL_CONTINUE__BTN, "ContinueClick")
Local $GUICTRL_OPENSUIT__BTN = GUICtrlCreateButton("Open", 184, 416, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_OPENSUIT__BTN, "OpenSuitClick")
Local $GUICTRL_RIGHTNEEDLE_BTN = GUICtrlCreateButton("->", 448, 296, 35, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_RIGHTNEEDLE_BTN, "RightNeedleClick") 
Local $Input1_FileName = GUICtrlCreateInput("IntegTest.ini", 16, 384, 385, 21)
    GUICtrlSetOnEvent($Input1_FileName, "Input1_FileNameChange")
Local $Input2_FileName = GUICtrlCreateInput("NewTestSuit.ini", 528, 384, 377, 21)
    GUICtrlSetOnEvent($Input2_FileName, "Input2_FileNameChange")
Local $Label1_CommSetting1 = GUICtrlCreateLabel("Common Settings:", 48, 296, 112, 20)
    GUICtrlSetFont($Label1_CommSetting1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label1_CommSetting1, "Label1_CommSetting1Click")
Local $Label2_CommSetting2 = GUICtrlCreateLabel("Common Settings:", 528, 296, 112, 20)
    GUICtrlSetFont($Label2_CommSetting2, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label2_CommSetting2, "Label2_CommSetting2Click")
Local $Label3_Port1 = GUICtrlCreateLabel("Port", 352, 272, 28, 20)
    GUICtrlSetFont($Label3_Port1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label3_Port1, "Label3_Port1Click")
Local $Label4_Port2 = GUICtrlCreateLabel("Port", 832, 272, 28, 20)
    GUICtrlSetFont($Label4_Port2, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label4_Port2, "Label4_Port2Click")
Local $Label5_Protocol1 = GUICtrlCreateLabel("Protocol", 280, 272, 54, 20)
    GUICtrlSetFont($Label5_Protocol1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label5_Protocol1, "Label5_Protocol1Click")
Local $Label6_Protocol2 = GUICtrlCreateLabel("Protocol", 760, 272, 54, 20)
    GUICtrlSetFont($Label6_Protocol2, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label6_Protocol2, "Label6_Protocol2Click")
Local $Label7_Device1 = GUICtrlCreateLabel("Device", 224, 272, 47, 20)
    GUICtrlSetFont($Label7_Device1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label7_Device1, "Label7_Device1Click")
Local $Label8_Device2 = GUICtrlCreateLabel("Device", 704, 272, 47, 20)
    GUICtrlSetFont($Label8_Device2, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label8_Device2, "Label8_Device2Click")
Local $Label9_OS1 = GUICtrlCreateLabel("OS", 176, 272, 23, 20)
    GUICtrlSetFont($Label9_OS1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label9_OS1, "Label9_OS1Click")
Local $Label10_OS2 = GUICtrlCreateLabel("OS", 656, 272, 23, 20)
    GUICtrlSetFont($Label10_OS2, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetOnEvent($Label10_OS2, "Label10_OS2Click")     
Local $Input3_Port1 = GUICtrlCreateInput("", 344, 296, 49, 21)
    GUICtrlSetBkColor($Input3_Port1, 0xFFFFFF)
    GUICtrlSetState($Input3_Port1, $GUI_DISABLE)
    GUICtrlSetOnEvent($Input3_Port1, "Input3_Port1Change")
Local $Input4_Protocol1 = GUICtrlCreateInput("", 280, 296, 57, 21)
    GUICtrlSetBkColor($Input4_Protocol1, 0xFFFFFF)
    GUICtrlSetState($Input4_Protocol1, $GUI_DISABLE)
    GUICtrlSetOnEvent($Input4_Protocol1, "Input4_Protocol1Change")
Local $Input5_Device1 = GUICtrlCreateInput("", 224, 296, 49, 21)
    GUICtrlSetBkColor($Input5_Device1, 0xFFFFFF)
    GUICtrlSetState($Input5_Device1, $GUI_DISABLE)
    GUICtrlSetOnEvent($Input5_Device1, "Input5_Device1Change")
Local $Input6_OS1 = GUICtrlCreateInput("", 168, 296, 49, 21)
    GUICtrlSetBkColor($Input6_OS1, 0xFFFFFF)
    GUICtrlSetState($Input6_OS1, $GUI_DISABLE)
    GUICtrlSetOnEvent($Input6_OS1, "Input6_OS1Change")
Local $Input7_OS2 = GUICtrlCreateInput("", 648, 296, 49, 21)
    GUICtrlSetOnEvent($Input7_OS2, "Input7_OS2Change")
Local $Input8_Device2 = GUICtrlCreateInput("", 704, 296, 49, 21)
    GUICtrlSetOnEvent($Input8_Device2, "Input8_Device2Change")
Local $Input9_Protocol2 = GUICtrlCreateInput("", 760, 296, 57, 21)
    GUICtrlSetOnEvent($Input9_Protocol2, "Input9_Protocol2Change")
Local $Input10_Port2 = GUICtrlCreateInput("", 824, 296, 49, 21)
    GUICtrlSetOnEvent($Input10_Port2, "Input10_Port2Change")    
    GUISetState(@SW_SHOW)

Share this post


Link to post
Share on other sites



tolyasher,

I am not spending my time writing a large number of functions and adding a long list of include files just to get your snippet to run - you have not even included the Opt("GUIOnEventMode", 1) line for heaven's sake! :D

If you want help then post something that runs so we can debug it - not just a collection of GUICtrlCreate* lines that might (or might not) make a pretty GUI.

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, thank for your remark. I have made this code workable and executable. I have deleted other not valuable parts. This aplication should load some info from file (ListView1) after pressing 'Open' button. After that user can select required rows from left side and transfer selected to the right side (ListView2) by pressing ">" after that it is possible to save new data to the new file.

So, execute, then press 'Open' then select row and press '>' after that it is supposed that user can change data in the ListView2 and save data to file. But I can not implement editing of ListView :D(

#include-once
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\koda\Templates\Test.kxf
Global $Paused  = False
Global $Started = False

Local $DualListDlg = GUICreate("Test", 921, 550, 202, 141, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetIcon("D:\007.ico")
GUISetOnEvent($GUI_EVENT_CLOSE, "DualListDlgClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "DualListDlgMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "DualListDlgMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "DualListDlgRestore")
;Local $ListView1 = GUICtrlCreateList("", 24, 32, 257, 227, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER))
Local $ListView1 = GUICtrlCreateListView("Test Number|Test Name                            |Device|Protocol|Port", 16, 32, 418, 230 )
    GUICtrlSetOnEvent($ListView1, "ListView1Click")
Local $ListViewItems1[10]   

Local $GUICTRL_RIGHTARROW_BTN = GUICtrlCreateButton(">", 448, 48, 30, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_RIGHTARROW_BTN, "RightArrowClick")
Local $GUICTRL_RUNTESTSUIT__BTN = GUICtrlCreateButton("Run", 424, 424, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_RUNTESTSUIT__BTN, "RunSuitClick")
Local $ListView2 = GUICtrlCreateListView("Test Number|Test Name                            |Device|Protocol|Port", 488, 32, 418, 230, BitOR($LVS_EDITLABELS, $LVS_SINGLESEL, $LVS_REPORT))
    GUICtrlSetOnEvent($ListView2, "ListView2Click")
Local $ListViewItems2[1]    
Local $GUICTRL_SAVESUIT_BTN = GUICtrlCreateButton("&Save", 688, 416, 75, 25,  $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_SAVESUIT_BTN, "SaveSuitClick")
Local $GUICTRL_EXIT_BTN = GUICtrlCreateButton("&Exit", 424, 488, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_EXIT_BTN, "ExitClick")

Local $GUICTRL_OPENSUIT__BTN = GUICtrlCreateButton("Open", 184, 416, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent($GUICTRL_OPENSUIT__BTN, "OpenSuitClick")

    GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Func RightArrowClick()

    Local $currentItem = GUICtrlRead(GUICtrlRead($ListView1))
    If UBound($ListViewItems2) ==1  Then
        $ListViewItems2[0] = GUICtrlCreateListViewItem($currentItem, $ListView2)
    Else
        _ArrayAdd($ListViewItems2, GUICtrlCreateListViewItem($currentItem, $ListView2))
    EndIf
    
EndFunc

Func SaveSuitClick()

EndFunc
Func ExitClick()
    Exit
EndFunc


Func RunSuitClick()
    ;CALLTIP: This function executed after pressing 'Run' button. Start to executing Test Suit
    $Started = NOT $Started                                                 ; Set flag TRUE  and start executing Test Suit
    GUICtrlSetState($GUICTRL_RUNTESTSUIT__BTN, $GUI_DISABLE)                ;  Disable 'Run' button 
EndFunc

Func ContinueClick()
    ;CALLTIP: This function executed after pressing 'Continue' button
    $Paused = NOT $Paused                                                   ; Set flag False  and continue executing Test Suit  
EndFunc

Func OpenSuitClick()
    For $index=0 To 9                                       ; Cycle goes over 
        $ListViewItems1[$index] = GUICtrlCreateListViewItem("Test"&$index&"|"&"Test"&$index&"|||"&"Test"&$index, $ListView1)
    Next    
EndFunc

Func DualListDlgClose()
    
    Exit
EndFunc

Func DualListDlgMaximize()

EndFunc
Func DualListDlgMinimize()

EndFunc
Func DualListDlgRestore()

EndFunc
Func ListView1Click()


EndFunc
Func ListView2Click()
  Local $result=   _GUICtrlListView_EditLabel($ListView2, 0)
EndFunc


While Not($Started)
    ;CALLTIP: This cycle like tap (stopper). Do not allow to start Test Suit. Suit will start just after pressing 'Run' button.
    Sleep(100)

WEnd

Share this post


Link to post
Share on other sites

tolyasher,

Sorry if I sounded tetchy, but as you could see it took a fair bit of effort to get that in runnable state - and you knew what you were doing. :D

I was busy searching the forum while you were away - it looks as if you have stumbled on one of the more intractable problems. :huggles:

The best i have come up with is a UDF from el torro, which martin updated here. It seems to create a child GUI over the ListView for the editing. Every other search result only allowed editing of the first column - which you have already achieved.

I hope this helps.

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 to you an rhanks to @eltorro. Combobox in the fourth column is decision for me! I'll try to implement it.

I thought about one more workaround: Below ListView control create Text Inputs controls for every column an copy data to inputs from selected row. After editing Text Inputs and pressing button "Store to Listview" update ListView columns with data from Text Inputs.

Thanks to you again!

Share this post


Link to post
Share on other sites

tolyasher,

Below ListView control create Text Inputs controls for every column an copy data to inputs from selected row

That was going to be my next suggestion! :D

Good luck - and please post whatever solution you come up with as this seems to be something that a lot of people have tried to do with little success.

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

At the end I've successfully used library from @eltorro. It was found that it is very easy )))

I listed below what I add to my code for including library from @eltorro;

#include <_EIPListView_my.au3> ; Include @eltorro library
Global $LVcolControl[5] = [1, 1, 2, 2, 2] ;left click actions ; I've used just 'edit' and 'combobox'
$Gui = $DualListDlg ; Copy handle to my GUI 
$__LISTVIEWCTRL = $ListView2         ; Copy handle to my listview

_InitEditLib ("", "", "", "Whatever", $Gui);
Local $c                 ; start filling combobox with data
For $i = 1 To 18            
    $c = $c & Chr($i + 66) & "|"    
Next                    
$c = StringTrimRight($c, 1)         
GUICtrlSetData($lvCombo, $c)      ; end filling combobox with data

While Not($Started)               ; Infinity Cycle  
  _MonitorEditState ($editCtrl, $editFlag, $__LISTVIEWCTRL, $LVINFO);<<<======  add this in your message loop<<<====== 
   If $bCALLBACK_EVENT = True Then
    $bCALLBACK_EVENT = False
    Call($LVCALLBACK, $LVINFO)
   EndIf
   Sleep(25)
WEnd

I attached files with my code and with @eltorro library. In the library I've commented string

;   $pos[0] = $aINFO[2] - (($aINFO[2]+$aINFO[4])- $ctrlSize[2])

_EIPListView_my.au3

SimpleCode.au3

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
Sign in to follow this  
Followers 0