Jump to content
Sign in to follow this  
Fire

ListView Problem

Recommended Posts

Fire

Firstly Hi to all .

My dears i have some troubles with My GUI program.

I create simple GUI program In Autoit.

It contains:

1:) Listview

2:) 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 ###################

value1

value2

value3

...

valuen..

################### CONTEXT OF TEST.TXT: FILE END OF FILE ######################

But my trouble in GUI Listview.It shows me this values as like below:

value1value2value3valuen

My Question: What is the right way for display this values in Listview like below:

value1

value2

value3

For 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:

#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]

Share this post


Link to post
Share on other sites
Zedna

#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

Share this post


Link to post
Share on other sites
Melba23

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
WEnd

Ans 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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Fire

Wow.Thank to all for help.Now i understand.Thank very very much.


[size="5"] [/size]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.