Page 1 of 1 1
Topic Options
#129973 - 2004-11-20 06:57 PM Listview sorted!?!?!
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
Damn i get mad of this.....

Could anyone provide an simple sample how to make a listview alphabetically sorted when reading and listing items from an ini file?

_________________________
I will always look out from behind these eyes...

Top
#129974 - 2004-11-20 07:01 PM Re: Listview sorted!?!?!
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ja, just set the ListView sorted property to true, like this:

$ListView.Sorted = "True"

-Shawn

Top
#129975 - 2004-11-21 01:21 AM Re: Listview sorted!?!?!
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
May I suggest to take a look at the KiXforms Manual? All these things are explained in it.
_________________________
There are two types of vessels, submarines and targets.

Top
#129976 - 2004-11-21 12:57 PM Re: Listview sorted!?!?!
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
I already test that.
Its not working...
The ini file is not alphabetically intact.
the listed items in listview is in same order as items are in ini file.
$ListView.Sorted = "True" seems not sort it properly.˝!"#
And why is that?
_________________________
I will always look out from behind these eyes...

Top
#129977 - 2004-11-21 01:02 PM Re: Listview sorted!?!?!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
first load the items to the listview and then set that property.
does that do the trick?

could also try sorting columns instead of the listview object.
_________________________
!

download KiXnet

Top
#129978 - 2004-11-21 02:20 PM Re: Listview sorted!?!?!
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Think I might know what it is ... The ListView only sorts items when the item is initially ADDED to the ListView, like this:

$Item = $ListView1.Items.Add("JazzM")

The ListView will insert this item alphabetically using "JazzM" as the sortkey, if you add the item like this however ...

$Item = $ListView1.Items.Add()
$Item.Text = "JazzM"

Thats not really the same as "adding" it - what this is really doing is adding an item with a null string, then CHANGING the name later (to JazzM), so might want to give that some thought ...

-Shawn

Top
#129979 - 2004-11-21 04:56 PM Re: Listview sorted!?!?!
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
So why is this not working?

$lsvList1 = $Form.ListView

$lsvList1.Height = 425
$lsvList1.Left = 12
$lsvList1.Top = 15
$lsvList1.Width = 200
$lsvList1.MultiSelect = 0
$lsvList1.Dock = "Left"
$lsvList1.OnDoubleClick = "lsvList1DC()"

$ = $lsvList1.Columns.Add("Name",180)
$ = $lsvList1.Columns.Add("Version",80)
$ = $lsvList1.Columns.Add("Path",0)
$ = $lsvList1.Columns.Add("ID",0)

$SWProd = "\\Server1\Share\Software1\Prroduct1.ini"

$Item0 = $lsvList1.Items.Add("")

$key = ReadProfileString($SWProd,"","")

For Each $Keys In Split($key,Chr(10))
If $Keys
$Item = $lsvList1.Items.Add()
$Item.Text = "Item"
$Name = ReadProfileString($SWProd,$Keys,"SWName")+@CRLF
$Item.Subitems(0).Text = $Name
$Ver = ReadProfileString($SWProd $Keys,"SWVersion")+@CRLF
$Item.Subitems(1).Text = $Ver
$Path = ReadProfileString($SWProd,$Keys,"SWPath")+@CRLF
$Item.Subitems(2).Text = $Path
$Item.Subitems(3).Text = $Keys
$NmVr = $Name + $Ver


$lsvList1.Columns.Sorted = "True"
$lsvList1.item.Sorted = "True"

$lsvList1.HideSelection = "true"
EndIf

I have 3 listviews reading items from 3 diffrent ini files plased on diffrent servers.

hmmm... what about listbox instead of listview...
_________________________
I will always look out from behind these eyes...

Top
#129980 - 2004-11-21 05:11 PM Re: Listview sorted!?!?!
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Because the ListView is set to sorted, after the items have already been added to it, try telling the listview to use sorting before items are added.
Top
#129981 - 2004-11-21 09:33 PM Re: Listview sorted!?!?!
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
$lsvList1 = $Form.ListView
$lsvList1.item.Sorted = "True"

is it before enough...
seems it doesn´t matter where i put it...
not working



Edited by JazzM (2004-11-21 09:35 PM)
_________________________
I will always look out from behind these eyes...

Top
#129982 - 2004-11-21 09:53 PM Re: Listview sorted!?!?!
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Why don't you take ALL of Shawn's advice instead of just cherry-picking what you want? He already told you not to add a null item.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#129983 - 2004-11-22 01:22 AM Re: Listview sorted!?!?!
Anonymous
Unregistered


Well, instead of this

$lsvList1.item.Sorted = "True"

it looks more like this:

$lsvList1.Sorted = "True"

so do that first, then - when you go to add an item ,make sure you do this:

$Item = $lsvList1.Items.Add("Text")

and not this:

$Item = $lsvList1.Items.Add()
$Item.Text = "Text"



Edited by Jooel (2004-11-22 08:03 AM)

Top
#129984 - 2004-11-22 01:29 AM Re: Listview sorted!?!?!
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Come-on Shawn. The least you could do is stand up for your code. Logon and quit hiding.
Top
#129985 - 2004-11-22 02:19 PM Re: Listview sorted!?!?!
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
aj aj aj, my bad...

$key = ReadProfileString($SWProd,"","")

For Each $Keys In Split($key,Chr(10))
If $Keys

$lsvList1.Sorted = "True"

$Name = ReadProfileString($SWProd,$Keys,"SWName")+@CRLF
$Item = $lsvList1.Items.Add($Name)
$Item.Subitems(0).Text = $Name


...and it works!
_________________________
I will always look out from behind these eyes...

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.204 seconds in which 0.151 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org