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

Speed Of ListView (Populate)

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
mercury
KiXforms Regular
KiXforms Regular


Joined: 10 Aug 2005
Posts: 50

PostPosted: Wed May 10, 2006 3:46 pm    Post subject: Speed Of ListView (Populate) Reply with quote

Hi Shawn,

I've been playing with a text viewer based on a Listview. I have managed to get it to read files into it no problem but it seems very slow to populate. To simplify things I hacked together this code to determine if it was the file reading or just populating the listview that was the bottleneck. The slowness if evident with the sample 100 row x 10 column list below. Some of my files contain over 1700 lines and can take upward of 30 seconds load. Is there a quicker way?

Code:
Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(873,846) ;(Width,Height)
$Form1.Text = "Form1"
$Form1.Top = 0


$ListViewTest = $System.ListView()
$ListViewTest.Dock = 5  ;Fill
$ListViewTest.View = $System.View_Details
$nul = $Form1.Controls.Add($ListViewTest)

$Button1 = $System.Button()
$Button1.Dock = 2  ;Bottom
$Button1.FlatStyle = 3  ;System
$Button1.Text = "Populate ListView with 50 entries"
$Button1.Top = 789
$Button1.Click = "LoadListView()"
$nul = $Form1.Controls.Add($Button1)

$Form1.Show  ;Displays the Form



While $Form1.Visible
   $Nul = Execute($Form1.DoEvents())
Loop
Exit 0

Function LoadListView()
   
   ;Clear The LogOutput ListView
   $nul = $ListViewTest.Columns.Clear
   $nul = $ListViewTest.Items.Clear

$ListViewTestColumn0 = $ListViewTest.Columns.Add($System.ColumnHeader("Item Column",100,$System.HorizontalAlignment_Left))
$ListViewTestColumn1 = $ListViewTest.Columns.Add($System.ColumnHeader("Column A",100,$System.HorizontalAlignment_Leftr))
$ListViewTestColumn2 = $ListViewTest.Columns.Add($System.ColumnHeader("Column B",100,$System.HorizontalAlignment_Left))
$ListViewTestColumn3 = $ListViewTest.Columns.Add($System.ColumnHeader("Column C",60,$System.HorizontalAlignment_Left))
$ListViewTestColumn4 = $ListViewTest.Columns.Add($System.ColumnHeader("Column D",60,$System.HorizontalAlignment_Left))
$ListViewTestColumn5 = $ListViewTest.Columns.Add($System.ColumnHeader("Column E",60,$System.HorizontalAlignment_Left))
$ListViewTestColumn6 = $ListViewTest.Columns.Add($System.ColumnHeader("Column F",60,$System.HorizontalAlignment_Left))
$ListViewTestColumn7 = $ListViewTest.Columns.Add($System.ColumnHeader("Column G",60,$System.HorizontalAlignment_Left))
$ListViewTestColumn8 = $ListViewTest.Columns.Add($System.ColumnHeader("Column H",60,$System.HorizontalAlignment_Left))
$ListViewTestColumn9 = $ListViewTest.Columns.Add($System.ColumnHeader("Column I",60,$System.HorizontalAlignment_Left))

For $x  = 0 To 100
      
   $ListViewTestItem00 = $ListViewTest.Items.Add($System.ListViewItem("Item " + $x))
   $ListViewTestItem01 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "A"))
   $ListViewTestItem02 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "B"))
   $ListViewTestItem03 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "C"))
   $ListViewTestItem04 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "D"))
   $ListViewTestItem05 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "E"))
   $ListViewTestItem06 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "F"))
   $ListViewTestItem07 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "G"))
   $ListViewTestItem08 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "H"))
   $ListViewTestItem09 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "I"))

Next
  $y = 0
   For Each $Column In $ListViewTest.Columns
      $ListViewTest.Columns.Item($y).Width = -2
      $y = $y + 1
   Next
   
EndFunction
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Wed May 10, 2006 4:07 pm    Post subject: Reply with quote

yeah, try this - before your loop do a BeginUpdate and after your loop do an EndUpdate, like this:

Code:

 $ListViewTest.BeginUpdate ; <--- here

 For $x  = 0 To 100
     
   $ListViewTestItem00 = $ListViewTest.Items.Add($System.ListViewItem("Item " + $x))
   $ListViewTestItem01 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "A"))
   $ListViewTestItem02 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "B"))
   $ListViewTestItem03 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "C"))
   $ListViewTestItem04 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "D"))
   $ListViewTestItem05 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "E"))
   $ListViewTestItem06 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "F"))
   $ListViewTestItem07 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "G"))
   $ListViewTestItem08 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "H"))
   $ListViewTestItem09 = $ListViewTest.Items.Item($x).SubItems.Add($System.ListViewSubItem("Item "+ $x + "I"))

 Next

 $y = 0
 For Each $Column In $ListViewTest.Columns
  $ListViewTest.Columns.Item($y).Width = -2
  $y = $y + 1
 Next
   
 $ListViewTest.EndUpdate ; <--- and here


Try moving the BeginUpdate higher, for even better results. Never have an un-matched pair of these things.
Back to top
View user's profile Send private message
mercury
KiXforms Regular
KiXforms Regular


Joined: 10 Aug 2005
Posts: 50

PostPosted: Wed May 10, 2006 10:17 pm    Post subject: Reply with quote

Hi Shawn,

That made a huge difference!

Thank you.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion 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