<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Instant Searching and Filtering in .Net &#8211; Part 4</title>
	<atom:link href="http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/</link>
	<description>Code and musings by Ben Watson</description>
	<lastBuildDate>Sat, 04 Feb 2012 04:16:32 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ben</title>
		<link>http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/comment-page-1/#comment-129146</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Mon, 18 Jan 2010 22:27:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/#comment-129146</guid>
		<description>@Rich, thanks, I&#039;ll look into that.</description>
		<content:encoded><![CDATA[<p>@Rich, thanks, I&#8217;ll look into that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/comment-page-1/#comment-128667</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Wed, 13 Jan 2010 22:06:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/#comment-128667</guid>
		<description>Hi Ben,

In your RetrieveVirtualItem section you mention that the if block should never be called, but you&#039;ve seen it once during debugging - using the scroll wheel on a mouse I see this block hit multiple times.  

Rich</description>
		<content:encoded><![CDATA[<p>Hi Ben,</p>
<p>In your RetrieveVirtualItem section you mention that the if block should never be called, but you&#8217;ve seen it once during debugging &#8211; using the scroll wheel on a mouse I see this block hit multiple times.  </p>
<p>Rich</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/comment-page-1/#comment-57502</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Fri, 29 Aug 2008 12:21:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/#comment-57502</guid>
		<description>Thanks Leon, I will definitely find that tip useful.</description>
		<content:encoded><![CDATA[<p>Thanks Leon, I will definitely find that tip useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leon Breedt</title>
		<link>http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/comment-page-1/#comment-57441</link>
		<dc:creator>Leon Breedt</dc:creator>
		<pubDate>Fri, 29 Aug 2008 03:35:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/#comment-57441</guid>
		<description>Hi Ben,

Another thing that we have encountered in virtual mode is that for large numbers of records, where there is a considerable perf hit to retrieving even just a subset of the records, the ListView scrolling behaviour makes the list less usable.

While WPF has deferred scrolling behaviour, this isn&#039;t available by default (at least not that I could find) in the WinForms listview.

A bit of a hack, but thanks to http://www.microsoft.com/msj/1299/c/c1299.aspx I was able to cook something up that makes the WinForms listview also use &quot;deferred&quot; scrolling behaviour (e.g. only when the thumb is released, does the scroll happen), which has improved the user experience immensely.

Here&#039;s the code (no idea how it&#039;s going to render as a comment though):

public class DeferredScrollingListView : System.Windows.Forms.ListView
{
    const int WM_VSCROLL=0x0115;
    const int SB_THUMBPOSITION=0x4;
    const int SB_THUMBTRACK=0x5;

    protected override void WndProc(ref System.Windows.Forms.Message m)
    {
        if( m.Msg==WM_VSCROLL )
        {
            int wParam=m.WParam.ToInt32();
            if( ((short)wParam)==SB_THUMBTRACK )
            {
                if( ignoreThumbTracks_ )
                {
                    return;
                }
            }
            else if( ((short)wParam)==SB_THUMBPOSITION )
            {
                ignoreThumbTracks_=false;
                SendMessage(m.HWnd,WM_VSCROLL,MakeWParam(SB_THUMBTRACK,((short)wParam&lt;&lt;16)),m.LParam);
                ignoreThumbTracks_=true;
            }
        }

        base.WndProc(ref m);
    }

    [DllImport(&quot;user32.dll&quot;,CharSet=CharSet.Auto)]
    static extern IntPtr SendMessage(IntPtr hWnd,int msg,IntPtr wParam,IntPtr lParam);

    static IntPtr MakeWParam(int loWord,int hiWord)
    {
        return new IntPtr((loWord&amp;0xFFFF)+((hiWord&amp;0xFFFF)&lt;&lt;16));
    }

    bool ignoreThumbTracks_=true;
}</description>
		<content:encoded><![CDATA[<p>Hi Ben,</p>
<p>Another thing that we have encountered in virtual mode is that for large numbers of records, where there is a considerable perf hit to retrieving even just a subset of the records, the ListView scrolling behaviour makes the list less usable.</p>
<p>While WPF has deferred scrolling behaviour, this isn&#8217;t available by default (at least not that I could find) in the WinForms listview.</p>
<p>A bit of a hack, but thanks to <a href="http://www.microsoft.com/msj/1299/c/c1299.aspx" rel="nofollow">http://www.microsoft.com/msj/1299/c/c1299.aspx</a> I was able to cook something up that makes the WinForms listview also use &#8220;deferred&#8221; scrolling behaviour (e.g. only when the thumb is released, does the scroll happen), which has improved the user experience immensely.</p>
<p>Here&#8217;s the code (no idea how it&#8217;s going to render as a comment though):</p>
<p>public class DeferredScrollingListView : System.Windows.Forms.ListView<br />
{<br />
    const int WM_VSCROLL=0&#215;0115;<br />
    const int SB_THUMBPOSITION=0&#215;4;<br />
    const int SB_THUMBTRACK=0&#215;5;</p>
<p>    protected override void WndProc(ref System.Windows.Forms.Message m)<br />
    {<br />
        if( m.Msg==WM_VSCROLL )<br />
        {<br />
            int wParam=m.WParam.ToInt32();<br />
            if( ((short)wParam)==SB_THUMBTRACK )<br />
            {<br />
                if( ignoreThumbTracks_ )<br />
                {<br />
                    return;<br />
                }<br />
            }<br />
            else if( ((short)wParam)==SB_THUMBPOSITION )<br />
            {<br />
                ignoreThumbTracks_=false;<br />
                SendMessage(m.HWnd,WM_VSCROLL,MakeWParam(SB_THUMBTRACK,((short)wParam&lt;&lt;16)),m.LParam);<br />
                ignoreThumbTracks_=true;<br />
            }<br />
        }</p>
<p>        base.WndProc(ref m);<br />
    }</p>
<p>    [DllImport("user32.dll",CharSet=CharSet.Auto)]<br />
    static extern IntPtr SendMessage(IntPtr hWnd,int msg,IntPtr wParam,IntPtr lParam);</p>
<p>    static IntPtr MakeWParam(int loWord,int hiWord)<br />
    {<br />
        return new IntPtr((loWord&amp;0xFFFF)+((hiWord&amp;0xFFFF)&lt;&lt;16));<br />
    }</p>
<p>    bool ignoreThumbTracks_=true;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Alexander</title>
		<link>http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/comment-page-1/#comment-24739</link>
		<dc:creator>Lee Alexander</dc:creator>
		<pubDate>Wed, 14 Nov 2007 10:21:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/#comment-24739</guid>
		<description>Hi Ben,

Interesting article, FYI I coordinate an open source project on CodePlex called Supelist which is a outlook style list view you might be interested at looking at.

www.CodePlex.com/Superlist

Carry on with the good work :-)

Regards
Lee</description>
		<content:encoded><![CDATA[<p>Hi Ben,</p>
<p>Interesting article, FYI I coordinate an open source project on CodePlex called Supelist which is a outlook style list view you might be interested at looking at.</p>
<p><a href="http://www.CodePlex.com/Superlist" rel="nofollow">http://www.CodePlex.com/Superlist</a></p>
<p>Carry on with the good work <img src='http://www.philosophicalgeek.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Regards<br />
Lee</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philosophical Geek &#187; Instant Searching and Filtering in .Net - Part 1</title>
		<link>http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/comment-page-1/#comment-24687</link>
		<dc:creator>Philosophical Geek &#187; Instant Searching and Filtering in .Net - Part 1</dc:creator>
		<pubDate>Tue, 13 Nov 2007 23:48:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.philosophicalgeek.com/2007/11/13/instant-searching-and-filtering-in-net-part-4/#comment-24687</guid>
		<description>[...] Efficient usage of ListView with filtering [...]</description>
		<content:encoded><![CDATA[<p>[...] Efficient usage of ListView with filtering [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

