Jump to content
Sign in to follow this  
trescon

Listview not View

Recommended Posts

trescon

Hi, I have the following program that I 'was suggested by Melba that worked for a. Csv file.

Now I've got the same routine, I added a larger number of columns and the list view does not show me anything, but it appears empty.

I would like to understand why not now be more '.

In the first part of the routine (the one before the _main ()) I read the file properly and the mold in the console.

Inside the _main () is the same routine but do not see anything in the listview.

Who knows how to help me to understand where I'm wrong, it seems to me all the same as the one that worked.

thanks

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <datetimeconstants.au3>
#include <array.au3>
#include <File.au3>
#include <GuiListView.au3>


global $dati,$Lines [1000],$aItems[1000]
dim $datix[1000][22], $columns [22]
; *******************+
$Form1 = GUICreate("Lettura", 900, 600, 100, 50)

$Button1 = GUICtrlCreateButton("Conferma", 600, 500, 95, 35)
GUICtrlSetFont(-1, 16, 800, 0, "Calibri")
GUISetState(@SW_SHOW)

While 1

Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Button1

_Main()
EndSwitch
WEnd

; *********************
dim $cont=0 , $cont1=0
$Lines = StringSplit(FileRead("C:\AutoIt\Progetti\Backorder\backorder.csv"), @CRLF, 1)

For $i = 2 To $lines[0]
ConsoleWrite('line:' & $i & ' ')
$columns = StringSplit($lines[$i], ";")
For $j = 1 To $columns[0]
ConsoleWrite('col' & $j & ':' & $columns[$j] & ' ')
$datix[$i][$j] =$columns[$j]
Next
ConsoleWrite(@CRLF)
Next

Func _Main()

$View=GUICreate("Backorder", 900, 400,100,50)

Local $hListView = GUICtrlCreateListView("", 2, 2, 894, 340)

; Add column
_GUICtrlListView_AddColumn($hListView, "Cod. Cli", 10)
_GUICtrlListView_AddColumn($hListView, "Cliente", 10)
_GUICtrlListView_AddColumn($hListView, "Ordine", 10)
_GUICtrlListView_AddColumn($hListView, "Data Ord.", 70)
_GUICtrlListView_AddColumn($hListView, "Codice", 60)
_GUICtrlListView_AddColumn($hListView, "Descrizione", 250)
_GUICtrlListView_AddColumn($hListView, "Q. Residua", 50)
_GUICtrlListView_AddColumn($hListView, "Q. Acc.", 50)
_GUICtrlListView_AddColumn($hListView, "Q. in Sped.", 50)
_GUICtrlListView_AddColumn($hListView, "Data Richiesta", 5)
_GUICtrlListView_AddColumn($hListView, "Data Conferma", 5)
_GUICtrlListView_AddColumn($hListView, "Riferimento", 80)
_GUICtrlListView_AddColumn($hListView, "Modello", 150)
_GUICtrlListView_AddColumn($hListView, "Valore Un.", 50)
_GUICtrlListView_AddColumn($hListView, "Giac.", 50)
_GUICtrlListView_AddColumn($hListView, "Ord. Forn.", 50)
_GUICtrlListView_AddColumn($hListView, "Ord. Cli", 50)
_GUICtrlListView_AddColumn($hListView, "In Sped.", 50)
_GUICtrlListView_AddColumn($hListView, "Dispo.", 50)
_GUICtrlListView_AddColumn($hListView, "Data Aprox.", 50)
_GUICtrlListView_AddColumn($hListView, "Q. Prox. Arr.", 50)
; _GUICtrlListView_AddColumn($hListView, "Www", 200)
;_GUICtrlListView_AddColumn($hListView, "Www", 200)

GUISetState()


; Add items
_GUICtrlListView_BeginUpdate($hListView)
; Loop through the file
For $b = 2 To $Lines[0]
; Split the line on the "#" characters
$aItems = StringSplit($Lines[$b], ";")
; Add the first item
Local $iItem = _GUICtrlListView_AddItem($hListView, $aItems[1], 1, 12)
; And then loop through the rest adding them as sub-items
For $i = 2 To $aItems[0]
_GUICtrlListView_AddSubItem($hListView, $iItem, $aItems[$i], $i - 1)
Next
Next
_GUICtrlListView_EndUpdate($hListView)
; Scroll control 500 pixels
_GUICtrlListView_Scroll($hListView, 0, 1000)
GUISetState(@SW_SHOW)

While 1

Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete($View)
ExitLoop

EndSwitch
WEnd


EndFunc ;==>_Main

does not allow me to loading the file that I use as a source csv. :

Error You aren't permitted to upload this kind of file


Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Share this post


Link to post
Share on other sites
Melba23

trescon,

Rename the file with a .txt extension - it should then upload. :)

And looking at the script I see you are adding data to a native ListView with the UDF functions - do you have a good reason for this? I would not recommend mixing the 2 methods. ;)

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
trescon

Hi Melba, I don't understand what you are referring to manuals and additions to UDF refer.

The routine is as to how you me you kindly set up.

I haven't added anything to the procedure itself.

I ask you please to be more clear and precise with a donkey in autoit.

Thank you

Edited by trescon

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Share this post


Link to post
Share on other sites
careca

Maybe it would be easier with the said csvtxt file.

Please add the file so we can take a look at it.

Maybe the way the file is read has something to do with the problem.


Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
AutoBert

Your FileRead is ececuted after ending of the script. Try this:

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <datetimeconstants.au3>
#include <array.au3>
#include <File.au3>
#include <GuiListView.au3>


Global $dati, $Lines[1000], $aItems[1000]
Dim $datix[1000][22], $columns[22]
; *******************+
; <============ Begin moved
Dim $cont = 0, $cont1 = 0
$Lines = StringSplit(FileRead("C:\AutoIt\Progetti\Backorder\backorder.csv"), @CRLF, 1)

For $i = 2 To $Lines[0]
    ConsoleWrite('line:' & $i & ' ')
    $columns = StringSplit($Lines[$i], ";")
    For $j = 1 To $columns[0]
        ConsoleWrite('col' & $j & ':' & $columns[$j] & ' ')
        $datix[$i][$j] = $columns[$j]
    Next
    ConsoleWrite(@CRLF)
Next
; <============ End moved

$Form1 = GUICreate("Lettura", 900, 600, 100, 50)

$Button1 = GUICtrlCreateButton("Conferma", 600, 500, 95, 35)
GUICtrlSetFont(-1, 16, 800, 0, "Calibri")
GUISetState(@SW_SHOW)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1

            _Main()
    EndSwitch
WEnd


Func _Main()

    $View = GUICreate("Backorder", 900, 400, 100, 50)

    Local $hListView = GUICtrlCreateListView("", 2, 2, 894, 340)

    ; Add column
    _GUICtrlListView_AddColumn($hListView, "Cod. Cli", 10)
    _GUICtrlListView_AddColumn($hListView, "Cliente", 10)
    _GUICtrlListView_AddColumn($hListView, "Ordine", 10)
    _GUICtrlListView_AddColumn($hListView, "Data Ord.", 70)
    _GUICtrlListView_AddColumn($hListView, "Codice", 60)
    _GUICtrlListView_AddColumn($hListView, "Descrizione", 250)
    _GUICtrlListView_AddColumn($hListView, "Q. Residua", 50)
    _GUICtrlListView_AddColumn($hListView, "Q. Acc.", 50)
    _GUICtrlListView_AddColumn($hListView, "Q. in Sped.", 50)
    _GUICtrlListView_AddColumn($hListView, "Data Richiesta", 5)
    _GUICtrlListView_AddColumn($hListView, "Data Conferma", 5)
    _GUICtrlListView_AddColumn($hListView, "Riferimento", 80)
    _GUICtrlListView_AddColumn($hListView, "Modello", 150)
    _GUICtrlListView_AddColumn($hListView, "Valore Un.", 50)
    _GUICtrlListView_AddColumn($hListView, "Giac.", 50)
    _GUICtrlListView_AddColumn($hListView, "Ord. Forn.", 50)
    _GUICtrlListView_AddColumn($hListView, "Ord. Cli", 50)
    _GUICtrlListView_AddColumn($hListView, "In Sped.", 50)
    _GUICtrlListView_AddColumn($hListView, "Dispo.", 50)
    _GUICtrlListView_AddColumn($hListView, "Data Aprox.", 50)
    _GUICtrlListView_AddColumn($hListView, "Q. Prox. Arr.", 50)
    ; _GUICtrlListView_AddColumn($hListView, "Www", 200)
    ;_GUICtrlListView_AddColumn($hListView, "Www", 200)

    GUISetState()


    ; Add items
    _GUICtrlListView_BeginUpdate($hListView)
    ; Loop through the file
    For $b = 2 To $Lines[0]
        ; Split the line on the "#" characters
        $aItems = StringSplit($Lines[$b], ";")
        ; Add the first item
        Local $iItem = _GUICtrlListView_AddItem($hListView, $aItems[1], 1, 12)
        ; And then loop through the rest adding them as sub-items
        For $i = 2 To $aItems[0]
            _GUICtrlListView_AddSubItem($hListView, $iItem, $aItems[$i], $i - 1)
        Next
    Next
    _GUICtrlListView_EndUpdate($hListView)
    ; Scroll control 500 pixels
    _GUICtrlListView_Scroll($hListView, 0, 1000)
    GUISetState(@SW_SHOW)

    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($View)
                ExitLoop

        EndSwitch
    WEnd


EndFunc   ;==>_Main

Share this post


Link to post
Share on other sites
trescon

This is a File

Thank you

Backorder.txt


Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Share this post


Link to post
Share on other sites
Melba23

trescon,

AutoBert called it correctly above. ;)

Here is his script - but with amendments to use the native function to load the ListView items:

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <datetimeconstants.au3>
#include <array.au3>
#include <File.au3>
#include <GuiListView.au3>


Global $dati, $Lines[1000], $aItems[1000]
Global $datix[1000][22], $columns[22]
Global $cont = 0, $cont1 = 0
$Lines = StringSplit(FileRead("backorder.csv"), @CRLF, 1)

$Form1 = GUICreate("Lettura", 900, 600, 100, 50)

$Button1 = GUICtrlCreateButton("Conferma", 600, 500, 95, 35)
GUICtrlSetFont(-1, 16, 800, 0, "Calibri")
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _Main()
    EndSwitch
WEnd


Func _Main()

    $View = GUICreate("Backorder", 900, 400, 100, 50)

    Local $hListView = GUICtrlCreateListView("", 2, 2, 894, 340)

    ; Add column
    _GUICtrlListView_AddColumn($hListView, "Cod. Cli", 10)
    _GUICtrlListView_AddColumn($hListView, "Cliente", 10)
    _GUICtrlListView_AddColumn($hListView, "Ordine", 10)
    _GUICtrlListView_AddColumn($hListView, "Data Ord.", 70)
    _GUICtrlListView_AddColumn($hListView, "Codice", 60)
    _GUICtrlListView_AddColumn($hListView, "Descrizione", 250)
    _GUICtrlListView_AddColumn($hListView, "Q. Residua", 50)
    _GUICtrlListView_AddColumn($hListView, "Q. Acc.", 50)
    _GUICtrlListView_AddColumn($hListView, "Q. in Sped.", 50)
    _GUICtrlListView_AddColumn($hListView, "Data Richiesta", 5)
    _GUICtrlListView_AddColumn($hListView, "Data Conferma", 5)
    _GUICtrlListView_AddColumn($hListView, "Riferimento", 80)
    _GUICtrlListView_AddColumn($hListView, "Modello", 150)
    _GUICtrlListView_AddColumn($hListView, "Valore Un.", 50)
    _GUICtrlListView_AddColumn($hListView, "Giac.", 50)
    _GUICtrlListView_AddColumn($hListView, "Ord. Forn.", 50)
    _GUICtrlListView_AddColumn($hListView, "Ord. Cli", 50)
    _GUICtrlListView_AddColumn($hListView, "In Sped.", 50)
    _GUICtrlListView_AddColumn($hListView, "Dispo.", 50)
    _GUICtrlListView_AddColumn($hListView, "Data Aprox.", 50)
    _GUICtrlListView_AddColumn($hListView, "Q. Prox. Arr.", 50)
    ; _GUICtrlListView_AddColumn($hListView, "Www", 200)
    ;_GUICtrlListView_AddColumn($hListView, "Www", 200)

    ; Add items
    _GUICtrlListView_BeginUpdate($hListView)
    ; Loop through the file
    For $b = 2 To $Lines[0]
        ; Make each line an item by replacing the ; with |
        GUICtrlCreateListViewItem(StringReplace($Lines[$b], ";", "|"), $hListView)
    Next
    _GUICtrlListView_EndUpdate($hListView)
    ; Scroll control 500 pixels
    _GUICtrlListView_Scroll($hListView, 0, 1000)

    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($View)
                ExitLoop
        EndSwitch
    WEnd

EndFunc   ;==>_Main

I looked up the thread where we discussed filling ListViews and I see that I just left your original UDF code in place - had I written it myself from scratch, I would most certainly have used the native functions to fill a native ListView as in the above script. Sorry if I confused you. :)

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
trescon

Another thing, a coriosità to understand.

Because if I take off my first gui ($ Form1) the program I print to the console the breakdown of the file in rows and columns, and if I leave the gui (the $ Form1 to understand) I can not see the print on the console.

thanks


Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Share this post


Link to post
Share on other sites
Melba23

trescon,

I took that bit out as I assumed it was just for testing - but you can add it back in again very easily: :)

$Lines = StringSplit(FileRead("backorder.csv"), @CRLF, 1)
; Add these lines back into the script at this point
For $i = 2 To $Lines[0]
    ConsoleWrite('line:' & $i & ' ')
    $columns = StringSplit($Lines[$i], ";")
    For $j = 1 To $columns[0]
        ConsoleWrite('col' & $j & ':' & $columns[$j] & ' ')
        $datix[$i][$j] = $columns[$j]
    Next
    ConsoleWrite(@CRLF)
Next

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

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  

×