Jump to content

Recommended Posts

Posted (edited)

I want to use ENTER to Add to ListView and use ENTER to edit the ListView Items (by ListViewEdit UDF)

But It dont work!

Could anyone help me!!!

#Region ; GUI generated by GUIBuilderNxt Prototype 1.0

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <ListBoxConstants.au3>
#include <ListViewEditInput.au3>


Global $MainStyle = BitOR($WS_OVERLAPPED, $WS_CAPTION, $WS_SYSMENU, $WS_VISIBLE, $WS_CLIPSIBLINGS, $WS_MINIMIZEBOX)

Global $hMain = GuiCreate("MyGUI", 189, 186, -1, -1, $MainStyle)

Global $Input_1 = GuiCtrlCreateInput("", 20, 20, 80, 20)
Global $ADD = GuiCtrlCreateButton("ADD", 120, 20, 50, 20)
Global $List_3 = GuiCtrlCreateListView("Number | Name", 20, 50, 150, 130)

  Local $aAccelKeys[][] = [["{Enter}", $Add]]
   GUISetAccelerators($aAccelKeys)

   __ListViewEditInput_StartUp($hMain)
   ;add listview, only edit col 1 and 2, doubleclick
   __ListViewEditInput_AddListview($hMain,$List_3,"0,1")
   ;esc to cancel and enter to send
  ; __ListViewEditInput_InitializeKeys($hMain)
   ;register function, after editing a field
   __ListViewEditInput_RegisterFunction($List_3,"_edited","Changed")
   ;register Function, when field not edited
   __ListViewEditInput_RegisterFunction($List_3,"_canceled","Canceled")
            ;
GuiSetState(@SW_SHOWNORMAL)
Do
    Switch GuiGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case $Add
           $Name = GUICtrlRead($Input_1)
           $Number = ControlListView("MyGui", "", $List_3, "GetItemCount") + 1
           GUICtrlCreateListViewItem($Number & "|" & $Name , $List_3)
           GUICtrlSetData($Input_1, "")
           ControlClick("MyGui", "", '[CLASS:Edit; INSTANCE:1]', "left")

      EndSwitch
Until False
#EndRegion

P/S: The UDF I get from :

 

 

Edited by langthang084
Posted (edited)
  1. You can't use GUISetAccelerators when included ListViewEditInput.au3, because __ListViewEditInput_InitializeKeys() also uses GUISetAccelerators.
  2. Use  $Number = _GUICtrlListView_GetItemCount($List_3)+1
     
Edited by AutoBert
Posted

At first, you forgot to initialize the Enter and Escape key. Because of that, it would never do anything.

I have rewritten your Example and Edited my UDF, so you can pass your own Accelerator-Array (Except Enter and ESC. There you must give a function instead of the Control)

At the moment I have not enough time to edit the whole UDF, but after 16.02.2016 you can look there, I think I will add multiple Guis and Remove the use of Accelerators then.

YourProject.zip

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...