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

ListView Help...

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


Joined: 18 Mar 2003
Posts: 158

PostPosted: Thu Aug 28, 2003 3:43 pm    Post subject: ListView Help... Reply with quote

I am very new to using the ListView object in Kixforms...

Is there any way to keep the scrollbar at the bottom from popping up whenever the list is populated. None of the fields are stretching beyond the columns so I dont know why it keeps popping up the scrollbar.

Also...Is there any way to sort the listview?

$List.Sorted = 1 does not seem to be working...

Any help would be greatly appreciated.

I am using kixforms 2.30 b3 (2.3.0.41)...

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Thu Aug 28, 2003 4:12 pm    Post subject: Reply with quote

For the Scrollbars :

It seems not to be supported but have you tried : $Object.ScrollBars = 0 ?

On the other side you can always 'Size' the Column.Width by dividing the .ClientWidth of the Object by the amount of columns you got (Of course a bit trickier if the Size should not be even.

For the Sort:

Have you assigned the property .Sorted before or after populating the ListView ?

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Thu Aug 28, 2003 5:16 pm    Post subject: Reply with quote

On the scrollbars...I have tried the...$List.ScrollBars = 2 (vertical bar only) to no avail.

I have tried the sort property both before and after it is populated. Neither seems to sort it. I can still sort it by click the header at the top of the column so that isn't as big of a problem as the darn scroll bar.

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Thu Aug 28, 2003 5:38 pm    Post subject: Reply with quote

I realized the bottom scrollbar is to make up for the extra 21 pixels that the vertical scrollbars add when the list is populated. So I have gotten around it by making the column widths add up to 21 less than the listview width.

Is there any way to make the vertical scrollbar appear as soon as the list is built rather than only after it is populated?

Code:
$ComputerList = $Form.Controls.ListView
$ComputerList.Sorted = 1
$ComputerList.Top = 145
$ComputerList.Left = 20
$ComputerList.Width = 354
$ComputerList.Height = 315
$ComputerList.ScrollBars = 2
$PCColumn = $ComputerList.Columns.Add("PC",240,0)
$UPColumn = $ComputerList.Columns.Add("Up",47,0)
$SUColumn = $ComputerList.Columns.Add("SU",46,0)

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Thu Aug 28, 2003 6:40 pm    Post subject: Reply with quote

Yo Shane,

here is a related discussion (Sorting Listviews) about future implementations: http://www.kixforms.org/forum/viewtopic.php?t=145

I had success with this short test scripty using your sample :

Code:
break on

$PCList = "Onions","Apples","Strawberries","Anchovis","Oranges","Peas","Peaches","Grapes","Orang Utans"

$f = createobject("KiXtart.Form")
$f.Size = 600,600
$ComputerList = $f.Controls.ListView
$ComputerList.Sorted = 1
$ComputerList.Top = 145
$ComputerList.Left = 20
$ComputerList.Width = 354
$ComputerList.Height = 315
$ComputerList.ScrollBars = 2
$PCColumn = $ComputerList.Columns.Add("PC",240,0)
$UPColumn = $ComputerList.Columns.Add("Up",47,0)
$SUColumn = $ComputerList.Columns.Add("SU",46,0)

for each $item in $PClist
    $_ = $PCColumn.Items.Add($item)
next

$f.Show

while $f.Visible
    $=execute($f.DoEvents)
loop
exit 1



Think you either not use build 41 or you have a problem in your code elsewhere Confused

Can you test this against your version ? here it IS sorted

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Thu Aug 28, 2003 10:44 pm    Post subject: Reply with quote

Thanks for the help Jochen...

The code you sent me worked fine. The below modified to the method I use to insert into the list does not. Is there something wrong with doing it this way or is it some kind of bug?

Code:
break on

$f = createobject("KiXtart.Form")
$f.Size = 600,600
$ComputerList = $f.Controls.ListView
$ComputerList.Sorted = 1
$ComputerList.Top = 145
$ComputerList.Left = 20
$ComputerList.Width = 354
$ComputerList.Height = 315
$ComputerList.ScrollBars = 2
$PCColumn = $ComputerList.Columns.Add("PC",240,0)
$UPColumn = $ComputerList.Columns.Add("Up",47,0)
$SUColumn = $ComputerList.Columns.Add("SU",46,0)

$ComputerList.Items.Add.SubItems(0).Text = "Onions"
$ComputerList.Items.Add.SubItems(0).Text = "Apples"
$ComputerList.Items.Add.SubItems(0).Text = "Strawberrys"

$f.Show

while $f.Visible
    $=execute($f.DoEvents)
loop
exit 1

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 29, 2003 11:12 am    Post subject: Reply with quote

Hmmm .... I wonder why this way works anyway (well, except the sorting).

If I interpret these lines correctly,

Code:
$ComputerList.Items.Add.SubItems(0).Text = "Onions"
$ComputerList.Items.Add.SubItems(0).Text = "Apples"
$ComputerList.Items.Add.SubItems(0).Text = "Strawberrys"


I think what is going on here is that it adds empty items and then changes the text value of these in the same 'line' (not sure if I can say process instead of line), so it initially skips the sorting as for the empty items added Sceptic

You should anyway better populate your listview in adding items first like I showed and afterwards manipulate these by this:
$Object.Items(row).SubItems(column).Text = "whatever"

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Fri Aug 29, 2003 2:40 pm    Post subject: Reply with quote

You are correct...I changed from this...

Code:
$ComputerList.Items.Add.SubItems(0).Text = "Onions"
$ComputerList.Items.Add.SubItems(0).Text = "Apples"
$ComputerList.Items.Add.SubItems(0).Text = "Strawberrys"


To this...

Code:
$null = $PCColumn.Items.Add("Onions")
$null = $PCColumn.Items.Add("Apples")
$null = $PCColumn.Items.Add("Strawberrys")


It now sorts as expected. Thank you very much for all of your help.

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Wed Sep 03, 2003 11:31 pm    Post subject: Reply with quote

well...just when you think all is working well... Shocked

Still think there is something fishy with the listview sort property...

Code:
break on

$f = createobject("KiXtart.Form")
$f.Size = 600,600
$ComputerList = $f.Controls.ListView
$ComputerList.Sorted = 1
$ComputerList.Top = 145
$ComputerList.Left = 20
$ComputerList.Width = 354
$ComputerList.Height = 315
$ComputerList.ScrollBars = 2
$PCColumn = $ComputerList.Columns.Add("PC",240,0)
$UPColumn = $ComputerList.Columns.Add("Up",47,0)
$SUColumn = $ComputerList.Columns.Add("SU",46,0)

$null = $ComputerList.Items.Add("Onions")
$ComputerList.Items(0).SubItems(1).Text = "test"
$ComputerList.Items(0).SubItems(2).Text = "test2"
$null = $ComputerList.Items.Add("Strawberrys")
$ComputerList.Items(1).SubItems(1).Text = "test"
$ComputerList.Items(1).SubItems(2).Text = "test2"
$null = $ComputerList.Items.Add("Apples")
$ComputerList.Items(2).SubItems(1).Text = "test"
$ComputerList.Items(2).SubItems(2).Text = "test2"

$f.Show

while $f.Visible
    $=execute($f.DoEvents)
loop
exit 1


Does not act the way I would think it should...Where as the same code with the sort REMed out does...

Code:
break on

$f = createobject("KiXtart.Form")
$f.Size = 600,600
$ComputerList = $f.Controls.ListView
;$ComputerList.Sorted = 1
$ComputerList.Top = 145
$ComputerList.Left = 20
$ComputerList.Width = 354
$ComputerList.Height = 315
$ComputerList.ScrollBars = 2
$PCColumn = $ComputerList.Columns.Add("PC",240,0)
$UPColumn = $ComputerList.Columns.Add("Up",47,0)
$SUColumn = $ComputerList.Columns.Add("SU",46,0)

$null = $ComputerList.Items.Add("Onions")
$ComputerList.Items(0).SubItems(1).Text = "test"
$ComputerList.Items(0).SubItems(2).Text = "test2"
$null = $ComputerList.Items.Add("Strawberrys")
$ComputerList.Items(1).SubItems(1).Text = "test"
$ComputerList.Items(1).SubItems(2).Text = "test2"
$null = $ComputerList.Items.Add("Apples")
$ComputerList.Items(2).SubItems(1).Text = "test"
$ComputerList.Items(2).SubItems(2).Text = "test2"

$f.Show

while $f.Visible
    $=execute($f.DoEvents)
loop
exit 1


What is going on?

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Wed Sep 03, 2003 11:34 pm    Post subject: Reply with quote

okay...I can see why it is happening now.

By the time the Apples Item is being added it is becoming Index 0 and then still adding the text to Index 2...

But how would you resolve it? How do you add an Item and know what the index of the Item is if it going to be thrown into the list in alphabetical order? Since you dont know what the Index of the Item is going to be...How can you add SubItems to it?

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Wed Sep 03, 2003 11:48 pm    Post subject: Reply with quote

Nevermind...Im a moron. I thought the $null= above was only to keep console from popping up...When in fact it is a valid variable that can be used.

Got my post count increased a few anyways... Confused

Code:
break on

$f = createobject("KiXtart.Form")
$f.Size = 600,600
$ComputerList = $f.Controls.ListView
$ComputerList.Sorted = 1
$ComputerList.Top = 145
$ComputerList.Left = 20
$ComputerList.Width = 354
$ComputerList.Height = 315
$ComputerList.ScrollBars = 2
$PCColumn = $ComputerList.Columns.Add("PC",240,0)
$UPColumn = $ComputerList.Columns.Add("Up",47,0)
$SUColumn = $ComputerList.Columns.Add("SU",46,0)

$onions = $ComputerList.Items.Add("Onions")
$onions.SubItems(1).Text = "test"
$onions.SubItems(2).Text = "test2"
$strawberrys = $ComputerList.Items.Add("Strawberrys")
$strawberrys.SubItems(1).Text = "test"
$strawberrys.SubItems(2).Text = "test2"
$apples = $ComputerList.Items.Add("Apples")
$apples.SubItems(1).Text = "test"
$apples.SubItems(2).Text = "test2"

$f.Show

while $f.Visible
    $=execute($f.DoEvents)
loop
exit 1

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
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