﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Slow Listview Requery</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 06:25:03 GMT</lastBuildDate><ttl>20</ttl><item><title>Slow Listview Requery</title><link>http://forum.strataframe.net/FindPost22688.aspx</link><description>Hi to all.  I am populating a listview from a business object using the CopyDataFrom(BusinessLayerBase,BusinessCloneDataType) method. This business object can have up to about 1600 rows in it.  The issue here is that the lstview.Requery() method that is populating the listview from the rows in the business object is taking a long time. I should mention that this listview is on a tab that is not initially shown. The requery is really quick until the tab with the listview is shown the first time, even if it is hidden after that. (The listview is filled and queried on the navigate method of the primary business object.)  &lt;br&gt;
&lt;br&gt;
The StrataFrame source code where the slowness occurs is during the following for loop in the PopulateListView function in ListView.vb:&lt;br&gt;
&lt;br&gt;
 For lnCnt = 0 To loBO.Count - 1&lt;br&gt;
                    '-- Move to the row we need&lt;br&gt;
                    loBO.MoveAbsolute(lnCnt)&lt;br&gt;
&lt;br&gt;
                    '-- add the item to the list&lt;br&gt;
                    Me.Items.Add(CreateListViewItem(loBO))&lt;br&gt;
  Next&lt;br&gt;
&lt;br&gt;
Does anyone have any ideas?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Jared&lt;br&gt;</description><pubDate>Mon, 13 Apr 2009 08:22:53 GMT</pubDate><dc:creator>Jared Ewald</dc:creator></item><item><title>RE: Slow Listview Requery</title><link>http://forum.strataframe.net/FindPost22692.aspx</link><description>Well, in the code snippet you gave would be all of the slowest possible ways to enumerate a BO and create a list view item (though I didn't see the code behind your CredteListViewItem).&amp;nbsp; In this example, you are manually populating your ListView which requires a bit of optimization to prevent rendering and callbacks.&lt;/P&gt;&lt;P&gt;When manually populating a ListView, you will want to call the BeginUpdate() prior to loading:&lt;/P&gt;&lt;P&gt;[codesnippet]'-- Prevents events and rendering (will dramaticaly improve loading)&lt;BR&gt;MyListView.BeginUpdate()&lt;/P&gt;&lt;P&gt;'-- Populate Here&lt;/P&gt;&lt;P&gt;'-- When completed, end the update otherwise the list will not act right&lt;BR&gt;MyListView.EndUpdate()[/codesnippet]&lt;/P&gt;&lt;P&gt;Next, when you enumerate a BO, use the enumerator:&lt;/P&gt;&lt;P&gt;[codesnippet]For Each bo As MyBOType in MyBoInstance.GetEnumerable()&lt;BR&gt;&amp;nbsp;&amp;nbsp; '-- You now have a strong-typed reference and pointers, etc. will all be handled &lt;BR&gt;&amp;nbsp;&amp;nbsp; '&amp;nbsp;&amp;nbsp;&amp;nbsp; from within the enumerator&lt;BR&gt;&amp;nbsp;&amp;nbsp; MyListVIew.Items.Add(CreateListViewItem(bo))&lt;BR&gt;Next[/codesnippet]&lt;/P&gt;&lt;P&gt;But the best way would be to let the ListView populate for you as it already handles all of this.&amp;nbsp; Ust the PopulationDataSoruceSettings of the ListView to manage this for you.</description><pubDate>Mon, 13 Apr 2009 08:22:53 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>