yousefsamy Posted July 4, 2014 Posted July 4, 2014 i want to save contains of list(names-class-number) in a text file.. here is my code : expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form1 = GUICreate("Form1", 770, 500, 195, 134) $List = GUICtrlCreateListView("Name|Class|Number",240,250,300,200) $Button1 = GUICtrlCreateButton("Button1", 240, 168, 193, 41) $Button2 = GUICtrlCreateButton("save", 50, 168, 193, 41) $Input1 = GUICtrlCreateInput("Name", 260, 64, 249, 21) $Input2 = GUICtrlCreateInput("Class", 0, 64, 249, 21) $Input3 = GUICtrlCreateInput("Number", 550, 64, 249, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $readN = GUICtrlRead($Input1) $readC = GUICtrlRead($Input2) $readNum = GUICtrlRead($Input3) GUICtrlCreateListViewItem($readN&"|"&$readC&"|"&$readNum, $List) Case $Button2 $s = GUICtrlRead($List) $ss = FileSaveDialog("save",@DesktopDir,"TXT (*.txt)") FileWrite($ss,$s) EndSwitch WEnd
yousefsamy Posted July 4, 2014 Author Posted July 4, 2014 (edited) really i have made some thing to save only line by line in a text file here is my code : #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form1 = GUICreate("Form1", 770, 500, 195, 134) $List = GUICtrlCreateListView("Name|Class|Number",240,250,300,200) $Button1 = GUICtrlCreateButton("Button1", 240, 168, 193, 41) $Button2 = GUICtrlCreateButton("save", 50, 168, 193, 41) $Input1 = GUICtrlCreateInput("Name", 260, 64, 249, 21) $Input2 = GUICtrlCreateInput("Class", 0, 64, 249, 21) $Input3 = GUICtrlCreateInput("Number", 550, 64, 249, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $readN = GUICtrlRead($Input1) $readC = GUICtrlRead($Input2) $readNum = GUICtrlRead($Input3) $o = GUICtrlCreateListViewItem($readN&"|"&$readC&"|"&$readNum, $List) $s = GUICtrlRead($o) FileWriteLine(@WorkingDir&"\info.txt",$s) EndSwitch WEnd but i want to know can i save all things in the list by one click not line by line? Edited July 4, 2014 by yousefsamy
yousefsamy Posted July 4, 2014 Author Posted July 4, 2014 lorenkinzel how do you want to do it .. i don't know how to do it with your code
Moderators Melba23 Posted July 4, 2014 Moderators Posted July 4, 2014 yousefsamy,You were pretty close - this works for me: #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 770, 500, 195, 134) $List = GUICtrlCreateListView("Name|Class|Number", 240, 250, 300, 200) $Button1 = GUICtrlCreateButton("Button1", 240, 168, 193, 41) $Button2 = GUICtrlCreateButton("Save", 50, 168, 193, 41) $Input1 = GUICtrlCreateInput("Name", 260, 64, 249, 21) $Input2 = GUICtrlCreateInput("Class", 0, 64, 249, 21) $Input3 = GUICtrlCreateInput("Number", 550, 64, 249, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; Create text $sItemText = GUICtrlRead($Input1) & "|" & GUICtrlRead($Input2) & "|" & GUICtrlRead($Input3) ; Add text to ListView GUICtrlCreateListViewItem($sItemText, $List) ; Add text to file FileWriteLine(@ScriptDir & "\info.txt", $sItemText) EndSwitch WEndAs usual, please ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
yousefsamy Posted July 4, 2014 Author Posted July 4, 2014 (edited) - but it seems my second code only save 1 line no more? (I want to save all lines in the list by one click) - and i have another question if i have a txt file have like 1000 line can i show them in the list?(Reload) Edited July 4, 2014 by yousefsamy
Moderators Melba23 Posted July 4, 2014 Moderators Posted July 4, 2014 yousefsamy,Some people are never satisfied: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <File.au3> ; Declare an array to hold the ListView content Global $aLVText $sFile = @ScriptDir & "\info.txt" $Form1 = GUICreate("Form1", 770, 500, 195, 134) $List = GUICtrlCreateListView("Name|Class|Number", 240, 250, 300, 200) $Button1 = GUICtrlCreateButton("Save", 240, 168, 193, 41) $Button2 = GUICtrlCreateButton("Load", 50, 168, 193, 41) $Input1 = GUICtrlCreateInput("Name", 260, 64, 249, 21) $Input2 = GUICtrlCreateInput("Class", 0, 64, 249, 21) $Input3 = GUICtrlCreateInput("Number", 550, 64, 249, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; Create text $sItemText = GUICtrlRead($Input1) & "|" & GUICtrlRead($Input2) & "|" & GUICtrlRead($Input3) ; Add text to ListView GUICtrlCreateListViewItem($sItemText, $List) ; Now read ListView contents into an array ; Get count of items $iCount = _GUICtrlListView_GetItemCount($List) ; Create array to hold text Global $aLVText[$iCount] ; Now loop through the ListView and store contents For $i = 0 To $iCount - 1 $aLVText[$i] = _GUICtrlListView_GetItemTextString($List, $i) Next ; Delete any existing file If FileExists($sFile) Then FileDelete($sFile) EndIf ; Write new file _FileWriteFromArray($sFile, $aLVText) Case $Button2 ; Load file into an array _FileReadToArray($sFile, $aLVText, $FRTA_NOCOUNT) ; Load items into the ListView If Not @error Then For $i = 0 To UBound($aLVText) - 1 GUICtrlCreateListViewItem($aLVText[$i], $List) Next EndIf EndSwitch WEndAll clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
yousefsamy Posted July 4, 2014 Author Posted July 4, 2014 Yes It's clear but i have one more question but i will try first if i can't do it i will ask you ok and thanks alot
Moderators Melba23 Posted July 4, 2014 Moderators Posted July 4, 2014 yousefsamy, i will try first if i can't do it i will ask youAn excellent plan. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
yousefsamy Posted July 5, 2014 Author Posted July 5, 2014 Melba23 i have a small question that how to edit on any of lines in the list by another button ,, and another to delete and thanks alot
Moderators Melba23 Posted July 5, 2014 Moderators Posted July 5, 2014 yousefsamy,If you want to get a really flexible ListView I suggest you look at my GUIListViewEx UDF (the link is in my sig) which allows you to add, delete, move, edit, sort and drag items. Very easy to use and I will be happy to guide you through any integration problems. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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