Sign in to follow this  
Followers 0
gleem

Refresh List View and Sort List View items

11 posts in this topic

In the example code:

; LIST VIEW

$listView = GuiCtrlCreateListView("Sample|ListView|", 110, 190, 110, 80)

GuiCtrlCreateListViewItem("A|One", $listView)

GuiCtrlCreateListViewItem("B|Two", $listView)

GuiCtrlCreateListViewItem("C|Three", $listView)

two things I want to do.

First, I am pulling data from a text file in which gets updated every so often. is there a way for me to clear the current listviewitems data without exiting the program?

2nd,

how can I sort the listview items by clicking on the colum headers?

for example:

List A | List B |List C

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

1 2 3

4 5 6

2 4 9

lets say I want to sort list A so it displays lowest to highest number?

same with list b, c, etc....

Share this post


Link to post
Share on other sites



Beta

1. _GUICtrlListViewDeleteAllItems

2. _GUICtrlListViewSort or GUICtrlRegisterListViewSort function


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Beta

1. _GUICtrlListViewDeleteAllItems

2. _GUICtrlListViewSort or GUICtrlRegisterListViewSort function

for these functions.... what do I need to load these functions.... #guilist.au3? or something like that?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

for these functions.... what do I need to load these functions.... #guilist.au3? or something like that?

If you look in the beta help file, you'll see that they're defined in GuiListView.au3

Edit: I wasn't sure if your question was of syntax, or of file identification.

Try this:

#include <GuiListView.au3>
Edited by Skruge

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

If you look in the beta help file, you'll see that they're defined in GuiListView.au3

Edit: I wasn't sure if your question was of syntax, or of file identification.

Try this:

#include <GuiListView.au3>
when using _GuiCtrlListViewDeleteAllItems

I get an error parsing function call.

I am running in beta.

Share this post


Link to post
Share on other sites

Might want to post a short script that can reproduce the problem you are having.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Here is my code as it sits...

here is the encrypting file.

#include <string.au3>


;-------------------------------------------------------------
; Change time format from 24 hour to 12 hour.
;-------------------------------------------------------------

; Set hours prior to pm
    $NewHour = @HOUR
    $AMPM = ("AM")

; Change format.
    If @HOUR = 13 Then
        $NewHour = ("01")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 14 Then
        $NewHour = ("02")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 15 Then
        $NewHour = ("03")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 16 Then
        $NewHour = ("04")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 17 Then
        $NewHour = ("05")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 18 Then
        $NewHour = ("06")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 19 Then
        $NewHour = ("07")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 20 Then
        $NewHour = ("08")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 21 Then
        $NewHour = ("09")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 22 Then
        $NewHour = ("10")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 23 Then
        $NewHour = ("11")
        $AMPM = ("PM")
    EndIf

    If @HOUR = 24 Then
        $NewHour = ("12")
        $AMPM = ("PM")
    EndIf
    
; Start Main Code

$logfile = ("C:\SGI-Login\Log\Log-" & @MON & "-" & @MDAY & "-" & @YEAR & ".dat") 

$file = FileOpen($logfile, 1)
$count = 0

;Check if file opened for reading and writeOK

While 1
    
 If $file = -1 Then
    waiting()
    $count = $count + 1 
    $file = FileOpen($logfile, 1)
Else
    ExitLoop
EndIf

WEnd

$outputdata = (@ComputerName & "|" & @UserName & "|"& @MON & "-" & @MDAY & "-" & @YEAR & "|" & $NewHour & ":" & @MIN & " " & $AMPM & "|" & @LogonServer & "|" & @OSVersion & "|" & @OSServicePack & "|" & @IPAddress1)

$encrpttext = _StringEncrypt(1,$outputdata, "beta",2)

FileWriteLine($file, $encrpttext)

FileClose($file)
exit


Func waiting()
    
    if $count = 3 Then Exit
    sleep(60000)
    
EndFunc
Edited by gleem

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Here is my Viewer:

I want to be able to refresh as well as sort by cataglory.

#include <GuiConstants.au3>
#include <string.au3>
#include <GuiListView.au3>

; GUI
GuiCreate("SGI-Login Viewer", 800, 500)

; Menu
    $filemenu = GuiCtrlCreateMenu ("File")
    $fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu)
    $recentfilesmenu = GuiCtrlCreateMenu ("Recent Files",$filemenu)
    $separator1 = GuiCtrlCreateMenuitem ("",$filemenu)
    $exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu)
    
; LIST VIEW
    $listView = GuiCtrlCreateListView("Computer Name|User Name|Date Logged In|Time Logged In|Login Server|Windows Version|Service Pack|IP Address", 10,10,780,460)

    GUISetState()

; Loop

While 1
    $msg = GUIGetMsg()
    

    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        
        Case $msg = $fileitem

    $file = FileOpenDialog("Choose file...","C:\SGI-Login\Log\","DAT (*.DAT)")
    
        _GUICtrlListViewDeleteAllItems
    
; Get Data
    
            $open = FileOpen($file, 0)
            $linecount = 1

            While 1

                $readfile = Filereadline($open,$linecount)
                if $readfile = ("") Then Exitloop
                $decrypttext = _StringEncrypt(0, $readfile, "beta",2)
                GuiCtrlCreateListViewItem($decrypttext, $listView)
                $linecount = $linecount + 1
            WEnd

            FileClose($open)

            If @error <> 1 Then GuiCtrlCreateMenuItem ($file,$recentfilesmenu)
        
            GuiSetState()
                        
        Case $msg = $exititem
            ExitLoop
        
    EndSelect
WEnd

GUIDelete()

Exit
Edited by gleem

Share this post


Link to post
Share on other sites

_GUICtrlListViewDeleteAllItems($listView)
ahhh.. makes sense now :D thank you....

how about sorting? :wacko:

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  
Followers 0