langthang084 Posted January 22, 2016 Share Posted January 22, 2016 (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!!! expandcollapse popup#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 January 22, 2016 by langthang084 Link to comment Share on other sites More sharing options...
langthang084 Posted January 22, 2016 Author Share Posted January 22, 2016 And why number collum always 1? Link to comment Share on other sites More sharing options...
langthang084 Posted January 23, 2016 Author Share Posted January 23, 2016 Could anyone help meeeee Link to comment Share on other sites More sharing options...
AutoBert Posted January 23, 2016 Share Posted January 23, 2016 (edited) You can't use GUISetAccelerators when included ListViewEditInput.au3, because __ListViewEditInput_InitializeKeys() also uses GUISetAccelerators. Use $Number = _GUICtrlListView_GetItemCount($List_3)+1 Edited January 23, 2016 by AutoBert Link to comment Share on other sites More sharing options...
Kanashius Posted January 23, 2016 Share Posted January 23, 2016 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 langthang084 and AutoBert 2 My Website: Kanashius Webside (Some of my Programs you can find there) Link to comment Share on other sites More sharing options...
langthang084 Posted January 24, 2016 Author Share Posted January 24, 2016 Wow! Kanashius, thank you very much. You help me alot. Waiting for your new UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now