KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Need help with sorting filename (only numbers) in ListView

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
mima500
KiXforms Regular
KiXforms Regular


Joined: 11 Dec 2003
Posts: 48
Location: Sweden

PostPosted: Mon Nov 24, 2008 11:36 am    Post subject: Need help with sorting filename (only numbers) in ListView Reply with quote

Have a directory with many files with filenamn = dates (numbers only, for example 20081121_96000.txt). Want to sort these with the newest in the top. Tried Listbox but only sorting, but that showed me the oldest in the top. Changed to listview because there is an option .Sorting=Descending or Ascending.
Still dont work, same result ...

Code:

; Create form
$System = CreateObject("Kixtart.System")

$Form = $System.Form()
; ---- Size -------
$Form.Top    =  50
$Form.Left   = 150
$Form.Height = 700
$Form.Width  = 200
; -----------------
$Form.FontSize = 8,25
$Form.Text = "Show files"
$Form.MaximizeBox = "False"
$Form.MinimizeBox = "False"
$Form.ShowInTaskBar = "False"

$Message1             = $Form.Controls.Label()
$Message1.Top         = 10
$Message1.Left        = 15
$Message1.Height      = 35
$Message1.Width       = $Form.Width - 40
$Message1.Text        = "Choose file."
$Message1.FontSize    = 8
$Message1.Borderstyle = 2
$Message1.FontBold    = True

$ListView = $Form.Controls.ListView()
; ---- Size -------
$ListView.Top    = $Message1.Top + $Message1.Height
$ListView.Left   = $Message1.Left
$ListView.Height = $Form.Height - $Message1.Height- 130
$ListView.Width  = $Form.Width - 50
; -----------------
$ListView.FontSize = 8
$ListView.FontBold = True

;Column def
$Column = $ListView.Columns.Add("Filnamn",200,0)

$FileName = Dir("C:\Test")
While $FileName <> "" and @ERROR = 0
  If $FileName <> "." And $FileName <> ".."
   $Item = $ListView.Items.Add($FileName)
  Endif
  $FileName = Dir() ; retrieve next file
Loop
$Column.Sorting = "Ascending" ; Also tried Descending

$ListView.OnDoubleClick = "OK_Click()"

$ButtonHeight = 23
$ButtonWidth  = 50

$Button1 = $Form.Controls.Button()
; ---- Size -------
$Button1.Top    = $ListView.Height + $Message1.Height + 40
$Button1.Left   = $ListView.Left
$Button1.Height = $ButtonHeight
$Button1.Width  = $ButtonWidth
; -----------------
$Button1.FontSize = 8,25
$Button1.Text = "OK"
$Button1.OnClick = "OK_Click()"

$Button2 = $Form.Controls.Button()
; ---- Size -------
$Button2.Top    = $Button1.Top
$Button2.Left   = $Button1.Left + 55
$Button2.Height = $ButtonHeight
$Button2.Width  = $ButtonWidth
; -----------------
$Button2.Text = "Avsluta"
$Button2.FontSize = 8,25
$Button2.OnClick = "Cancel_Click()"


$Form.Show
$ListBox1.Focus
While $Form.Visible
 $=Execute($Form.DoEvents())
Loop
Exit 1
Function Cancel_Click()
 $Form.Hide
EndFunction

Function OK_Click()

 For Each $Item In $ListView.SelectedItems
  $ChosenFile = $Item.Text
 Next
 $File = "C:\Test\" + "$ChosenFile"
 Shell '%Comspec% /e:1024 /C "C:\Program Files (x86)\Microsoft Office\OFFICE11\WORDVIEW.EXE" $File'
EndFunction
Back to top
View user's profile Send private message
mima500
KiXforms Regular
KiXforms Regular


Joined: 11 Dec 2003
Posts: 48
Location: Sweden

PostPosted: Mon Nov 24, 2008 12:48 pm    Post subject: Reply with quote

Solved it trough a script on this site called phone.kix. Put the line:

Code:
$ListView.Sorting = 2

before the column declaration.

Also downloaded the latest kixforms.dll from 2006-06-20 (676kb)
Now it works with sorting Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group