Loc Posted August 18, 2020 Share Posted August 18, 2020 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $ GUI_Main = GUICreate ("Bán", 388, 410, 374, 148) $ ListView = GUICtrlCreateListView ("Số tiền | Tiền | Sản phẩm", 0, 0, 385, 200) GUICtrlSendMsg (-1, $ LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg (-1, $ LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg (-TH, 2, 180) GUICtrlCreateListViewItem ("1 | 20 $ | Cake", $ ListView) GUICtrlCreateListViewItem ("2 | 30 $ | Salt", $ ListView) GUICtrlCreateListViewItem ("3 | 50 $ | Egg", $ ListView) $ Button_Del = GUICtrlCreateButton ("DELETE", 50, 368, 121, 33) GUICtrlSetFont (-1, 12, 400, 0, "MS Sans Serif") $ Button_DelAll = GUICtrlCreateButton ("XÓA TẤT CẢ", 200, 368, 121, 33) GUICtrlSetFont (-1, 12, 400, 0, "MS Sans Serif") $ Edit = GUICtrlCreateEdit ("DELETE" & @ CRLF, 0,210,385,150) GUISetState (@SW_SHOW) $ AValues toàn cầu [1] [4] $ aValues [0] [0] = 0 Trong khi 1 $ nMsg = GUIGetMsg () Chuyển đổi $ nMsg Trường hợp $ Button_Del Xóa bỏ() Trường hợp $ Button_DelAll Xóa hết() Trường hợp $ GUI_EVENT_CLOSE Lối ra EndSwitch WEnd Func Delete () $ X địa phương Đối với $ x = $ aValues [0] [0] Đến 0 Bước -1 Nếu _GUICtrlListView_GetItemSelected ($ ListView, $ x) Thì _ArrayDelete ($ aValues, $ x + 1) $ aValues [0] [0] = $ aValues [0] [0] - 1 _GUICtrlListView_DeleteItem ($ ListView, $ x) GUICtrlSetData ($ Edit, "" & @ CRLF, 1) EndIf Kế tiếp EndFunc Func DeleteAll () _GUICtrlListView_DeleteAllItems ($ ListView) GUICtrlSetData ($ Edit, "" & @ CRLF, 1) EndFunc Edited September 7, 2020 by Loc Link to comment Share on other sites More sharing options...
Dan_555 Posted August 18, 2020 Share Posted August 18, 2020 (edited) Hi, expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $GUI_Main = GUICreate("Sell", 388, 410, 374, 148) $ListView = GUICtrlCreateListView("Amount|Money|Product", 0, 0, 385, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 180) GUICtrlCreateListViewItem("1|20$|Cake", $ListView) GUICtrlCreateListViewItem("2|30$|Salt", $ListView) GUICtrlCreateListViewItem("3|50$|Egg", $ListView) $Button_Del = GUICtrlCreateButton("DELETE", 50, 368, 121, 33) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button_DelAll = GUICtrlCreateButton("DELETE ALL", 200, 368, 121, 33) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Edit = GUICtrlCreateEdit("" & @CRLF, 0, 210, 385, 150) GUISetState(@SW_SHOW) Global $aValues[1][4] $aValues[0][0] = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button_Del Delete() Case $Button_DelAll DeleteAll() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Delete() Local $x For $x = $aValues[0][0] To 0 Step -1 If _GUICtrlListView_GetItemSelected($ListView, $x) Then _ArrayDelete($aValues, $x + 1) $aValues[0][0] = $aValues[0][0] - 1 MemoWrite($Edit, StringReplace(_GUICtrlListView_GetItemTextString($ListView, $x), "|", " ") & @CRLF, 0) _GUICtrlListView_DeleteItem($ListView, $x) EndIf Next EndFunc ;==>Delete Func DeleteAll() Local $items=_GUICtrlListView_GetItemCount($ListView) If $items > 0 Then For $x = 0 To $items - 1 MemoWrite($Edit, StringReplace(_GUICtrlListView_GetItemTextString($ListView, $x), "|", " ") & @CRLF, 0) Next _GUICtrlListView_DeleteAllItems($ListView) $aValues="" Global $aValues[1][4] $aValues[0][0] = 0 EndIf EndFunc ;==>DeleteAll Func MemoWrite($ed, $sMessage = "", $clear = 1) If $clear = 1 Then GUICtrlSetData($ed, "") GUICtrlSetData($ed, $sMessage, $clear) EndFunc ;==>MemoWrite even if the single delete button does not work in this script, it should work with your 'other' full script. Edited August 18, 2020 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Zedna Posted August 28, 2020 Share Posted August 28, 2020 expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $GUI_Main = GUICreate("Sell", 388, 410, 374, 148) $ListView = GUICtrlCreateListView("Amount|Money|Product", 0, 0, 385, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 180) GUICtrlCreateListViewItem("1|20$|Cake", $ListView) GUICtrlCreateListViewItem("2|30$|Salt", $ListView) GUICtrlCreateListViewItem("3|50$|Egg", $ListView) $Button_Del = GUICtrlCreateButton("DELETE", 50, 368, 121, 33) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button_DelAll = GUICtrlCreateButton("DELETE ALL", 200, 368, 121, 33) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Edit = GUICtrlCreateEdit("DELETED:"&@CRLF,0,210,385,150) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button_Del Delete() Case $Button_DelAll DeleteAll() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Delete() $item = _GUICtrlListView_GetNextItem($ListView) ; current selected If $item = -1 Then Return MemoWrite(_GUICtrlListView_GetItemTextString($ListView, $item)) _GUICtrlListView_DeleteItem($ListView,$item) EndFunc Func DeleteAll() $n = _GUICtrlListView_GetItemCount($ListView) If $n = 0 Then Return For $i = 0 To $n - 1 MemoWrite(_GUICtrlListView_GetItemTextString($ListView, $i)) Next _GUICtrlListView_DeleteAllItems($ListView) EndFunc Func MemoWrite($text) $text = StringReplace($text, "|", ", ") GUICtrlSetData($Edit, $text & @CRLF, 1) EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search 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