Verssuss Posted April 20, 2020 Share Posted April 20, 2020 expandcollapse popup#include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <GUIListView.au3> #include <File.au3> #include <AutoItConstants.au3> $width = 670 $GUI = GUICreate("gui", 670, 500,@DesktopWidth - ($width + 1), 0) GUISetState() $ListView = GUICtrlCreateListView("Name|No Name|Surrname|Next Name|U cant do it name", 10, 200, 450, 250,$LVS_SHOWSELALWAYS) $LV = GUICtrlGetHandle($ListView) $menu_file = GUICtrlCreateMenu("File") $menu_file_save = GUICtrlCreateMenuItem("Save Settings", $menu_file) $menu_file_load = GUICtrlCreateMenuItem("Load Settings", $menu_file) GUICtrlCreateMenuItem("", $menu_file) For $i = 0 To 20 + 1 GUICtrlCreateListViewItem("name" & $i & "|how" & $i & "|you" & $i & "|doing" & $i & "|IT ????", $listview) Next $button_add = GUICtrlCreateButton("ADD 10 Items", 480, 180, 70, 25) $button_up = GUICtrlCreateButton("UP", 480, 210, 70, 25) $button_down = GUICtrlCreateButton("DOWN", 480, 240, 70, 25) $button_copy = GUICtrlCreateButton("COPY", 480, 270, 70, 25) $button_del_selected = GUICtrlCreateButton("DEL", 480, 300, 70, 25) $button_selectall = GUICtrlCreateButton("Select All", 480, 330, 70, 25) $button_exit = GUICtrlCreateButton("EXIT", 480, 370, 70, 25) $button_fix1 = GUICtrlCreateButton("fix1", 100, 100, 50, 25) $button_fix2 = GUICtrlCreateButton("fix2", 100, 150, 50, 25) While 1 Switch GUIGetMsg() Case $button_add For $i = 0 To 9 + 1 GUICtrlCreateListViewItem("name" & $i & "|how" & $i & "|you" & $i & "|doing" & $i & "|IT ????", $listview) Next Case $menu_file_save $file_save = FileSaveDialog("Choose a filename.", "", "Data (*.ini)", $FD_PROMPTOVERWRITE, $FD_PATHMUSTEXIST) For $i = 0 To _GUICtrlListView_GetItemCount($listview) -1 step 1 IniWrite($file_save, "procedura", _ _GUICtrlListView_GetItemText($ListView, $i, 0), _ _GUICtrlListView_GetItemText($ListView, $i, 1) & "|" & _ _GUICtrlListView_GetItemText($ListView, $i, 2) & "|" & _ _GUICtrlListView_GetItemText($ListView, $i, 3) & "|" & _ _GUICtrlListView_GetItemText($ListView, $i, 4)) Next Case $menu_file_load $file_load = FileOpenDialog("Choose a filename.", "", "Data (*.ini)", $FD_PATHMUSTEXIST) $List = IniReadSection($file_load, "procedura") For $i = 1 To UBound($List) - 1 GUICtrlCreateListViewItem($List[$i][0] & "|" & $List[$i][1], $ListView) Next Case $button_up if _GUICtrlListView_GetSelectedIndices($LV) = 0 then _GUICtrlListView_ClickItem($listview,0) MsgBox(0,"Error", "Cant Move This Item Up") Else Local $txt_selected[_GUICtrlListView_GetColumnCount($LV)+1] Local $txt_at_bottom[_GUICtrlListView_GetColumnCount($LV)+1] $aa_count_column = _GUICtrlListView_GetColumnCount($LV) $no = _GUICtrlListView_GetSelectedIndices($LV) _GUICtrlListView_ClickItem($listview,$no-1) For $z = 0 To $aa_count_column Step + 1 $txt_selected[$z] = _GUICtrlListView_GetItemText($LV,$no,$z) $txt_at_bottom[$z] = _GUICtrlListView_GetItemText($LV,$no-1,$z) _GUICtrlListView_SetItemText($LV, $no - 1, $txt_selected[$z],$z) _GUICtrlListView_SetItemText($LV, $no, $txt_at_bottom[$z],$z) Next EndIf Case $button_down if _GUICtrlListView_GetSelectedIndices($LV) + 1 = _GUICtrlListView_GetItemCount($LV) then _GUICtrlListView_ClickItem($listview,0) MsgBox(0,"Error", "Cant Move This Item Down") Else Local $txt_selected[_GUICtrlListView_GetColumnCount($LV)+1] Local $txt_at_top[_GUICtrlListView_GetColumnCount($LV)+1] $aa_count_column = _GUICtrlListView_GetColumnCount($LV) $no = _GUICtrlListView_GetSelectedIndices($LV) _GUICtrlListView_ClickItem($listview,$no+1) For $z = 0 To $aa_count_column Step + 1 $txt_selected[$z] = _GUICtrlListView_GetItemText($LV,$no,$z) $txt_at_top[$z] = _GUICtrlListView_GetItemText($LV,$no+1,$z) _GUICtrlListView_SetItemText($LV, $no + 1, $txt_selected[$z],$z) _GUICtrlListView_SetItemText($LV, $no, $txt_at_top[$z],$z) Next EndIf Case $button_del_selected $var = _GUICtrlListView_GetSelectedIndices($listview) If $var = 0 Then _GUICtrlListView_DeleteItemsSelected($ListView) _GUICtrlListView_ClickItem($listview,$var) Else _GUICtrlListView_DeleteItemsSelected($ListView) _GUICtrlListView_ClickItem($listview,$var-1) EndIf Case $button_copy $var = _GUICtrlListView_GetSelectedIndices($LV) _GUICtrlListView_CopyItems($ListView, $ListView) Case $button_selectall _GUICtrlListView_ClickItem($Listview, 0) For $i = 0 To _GUICtrlListView_GetItemCount($LV) Step 1 _GUICtrlListView_SetItemSelected($Listview, $i) Next Case $button_exit Exit EndSwitch WEnd Func _fix1() ;~ $no = _GUICtrlListView_GetSelectedIndices($LV) ;~ ConsoleWrite ($no) EndFunc Func _fix2() ;~ $no = _GUICtrlListView_GetSelectedIndices($LV) ;~ ConsoleWrite(_GUICtrlListView_GetItemTextString($LV,$no)) EndFunc i have so far my gui but there is problem with save function after u copy any element of Listview u can not save it anymore. how i can fix "save" function or replace with other function ? also plz any suggestion about the rest Link to comment Share on other sites More sharing options...
Aelc Posted April 21, 2020 Share Posted April 21, 2020 You should use an index. I mean i don't know what this list is for but you would have another value than "name"( & $i ) maybe ... or do you just wanna have constantly inputs? and then the copy works too for me Case $menu_file_save $index = _GUICtrlListView_GetItemCount($listview) $file_save = FileSaveDialog("Choose a filename.", "", "Data (*.ini)", $FD_PROMPTOVERWRITE, $FD_PATHMUSTEXIST) For $i = 0 To _GUICtrlListView_GetItemCount($listview) -1 step 1 IniWrite($file_save, "procedura", $i, _GUICtrlListView_GetItemText($ListView, $i, 0) & "|" & _ _GUICtrlListView_GetItemText($ListView, $i, 1) & "|" & _ _GUICtrlListView_GetItemText($ListView, $i, 2) & "|" & _ _GUICtrlListView_GetItemText($ListView, $i, 3) & "|" & _ _GUICtrlListView_GetItemText($ListView, $i, 4)) Next IniWrite($file_save, "procedura", "index",$index ) Case $menu_file_load $file_load = FileOpenDialog("Choose a filename.", "", "Data (*.ini)", $FD_PATHMUSTEXIST) $List = IniRead ( $file_load,"procedura","index","" ) For $i = 0 To $List - 1 GUICtrlCreateListViewItem(IniRead ( $file_load,"procedura",$i,""),$ListView) Next Verssuss 1 why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
Verssuss Posted April 21, 2020 Author Share Posted April 21, 2020 thanks 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