Fire Posted November 24, 2009 Share Posted November 24, 2009 Firstly Hi to all .My dears i have some troubles with My GUI program.I create simple GUI program In Autoit.It contains:1:) Listview2:) Buttons.This program`s prinsipe is very simple.When it launched it creates test.txt file.First time when it(test.txt file) created it not contains any data.But when user ON GUI type somedata on Inputbox and then push ADD button it writes this value to test.txt file.Everything is ok.Listview on GUI shows me what data writed to test.txt file but it unable correctly read @CRLF (in file this is a new lines).For example i open this file (test.txt file)(manually not from script)After user input its context (below)#################### CONTEXT OF TEST.TXT: FILE BEGIN OF FILE ###################value1value2value3...valuen..################### CONTEXT OF TEST.TXT: FILE END OF FILE ######################But my trouble in GUI Listview.It shows me this values as like below:value1value2value3valuenMy Question: What is the right way for display this values in Listview like below:value1value2value3For view my trouble pliz launch my script & you understand me.AND the my Second question about this script is:What is the right way to delete each selected line from test.txt ?(for select value from listview and push delete button)But i haven`t any idea how to do this...Thanks to all.Sorry for my "great" linguistic properties my script:expandcollapse popup#include <GUIConstants.au3> FileWrite("test.txt", "" & @CRLF) $a = FileRead("test.txt") $update1 = GUICtrlCreateList($a, 56, 24, 161, 175 ) $Form1 = GUICreate("Test Programi", 633, 235, 349, 197 ) $List1 = GUICtrlCreateList($a, 56, 24, 161, 175 ) $Button1 = GUICtrlCreateButton("ADD", 232, 56, 81, 25, 0) $Button2 = GUICtrlCreateButton("Delete", 232, 136, 81, 25, 0) $Button3 = GUICtrlCreateButton("EXIT", 440, 176, 105, 25, 0) $input = GUICtrlCreateInput("", 400, 56, 169, 21) $Button4 = GUICtrlCreateButton("View File", 232, 96, 81, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Exit Case $input FileWrite("test.txt", GUICtrlRead($input)& @CRLF) MsgBox(64, "Added", "This Value Was added to test.txt =>" & GUICtrlRead($input) ) $a = FileRead("test.txt") $update1 = GUICtrlCreateList($a, 56, 24, 161, 175 ) Case $Button3 Exit case $Button4 Run("cmd.exe /c test.txt", "", @SW_HIDE) sleep(5000) WinKill("test") EndSwitch WEnd [size="5"] [/size] Link to comment Share on other sites More sharing options...
Zedna Posted November 24, 2009 Share Posted November 24, 2009 #include <GUIConstants.au3> $a = 'a' & @CRLF & 'b' & @CRLF & 'c' $Form1 = GUICreate("Test Programi", 633, 235, 349, 197 ) $List1 = GUICtrlCreateList($a, 56, 24, 161, 175 ) $Button1 = GUICtrlCreateButton("Test", 232, 56, 81, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $a = StringReplace($a, @CRLF, '|') GUICtrlSetData($List1, '') ; clean previous GUICtrlSetData($List1, $a) ; add it with correct separator EndSwitch WEnd Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 24, 2009 Moderators Share Posted November 24, 2009 Sh3llC043r,Ans 1: You need to differentiate between the elements of the file. One way would be like this - you could use _FileListToArray to get the same result when reading in the values from a file:#include <GUIConstantsEx.au3> $sText = "value1" & @CRLF & "value2" & @CRLF & "value3" $aList = StringSplit($sText, @CRLF, 1) $hGUI = GUICreate("Test", 500, 500) $hLV = GUICtrlCreateListView(" ", 10, 10, 480, 480) For $i = 1 To $aList[0] GUICtrlCreateListViewItem($aList[$i], $hLV) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndAns 2. Look at _GUICtrlListView_DeleteItem 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 Link to comment Share on other sites More sharing options...
Fire Posted November 24, 2009 Author Share Posted November 24, 2009 Wow.Thank to all for help.Now i understand.Thank very very much. [size="5"] [/size] 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