{"id":109627,"date":"2024-04-08T07:00:00","date_gmt":"2024-04-08T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=109627"},"modified":"2024-04-10T15:21:39","modified_gmt":"2024-04-10T22:21:39","slug":"20240408-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20240408-00\/?p=109627","title":{"rendered":"How does the classic Win32 ListView handle incremental searching?"},"content":{"rendered":"<p>The classic Win32 ListView supports incremental search: You can start typing the name of an item to search for it. But it&#8217;s a bit more complicated than that.<\/p>\n<p>You see, there&#8217;s more than one way that people expect type-to-search to work. In one pattern, you type the first letter of the thing you want, and the system finds the first item that starts with that letter. If that&#8217;s not the one you want, you press that same letter again, and the system finds the second item that starts with that letter. Keep pressing that same letter until you get to the item you want. This is how list box searching worked in Windows 1.0.<\/p>\n<p>Another pattern is to type the first letter of the thing you want, and the system finds the first item that starts with that letter. If that&#8217;s not the one you want, then type the second letter of the thing you want, and the system finds the first item whose first two letters match the letters you typed. Keep typing more and more letters until you get to the item you want.<\/p>\n<p>Which pattern should the classic Win32 ListView control use?<\/p>\n<p><a title=\"Why Not Both? meme explanation\" href=\"https:\/\/knowyourmeme.com\/memes\/why-not-both-why-dont-we-have-both\"> Why not both<\/a>?<\/p>\n<p>If you type the same letter over and over again, then the classic Win32 ListView assumes that you are using the first pattern, and each time you press the same letter again, it selects the next item that starts with that letter. But if you type different letters, then the classic Win32 ListView assumes that you are typing a prefix, and it selects the first item that starts with that prefix.<\/p>\n<p>For example, suppose that you have a ListView with the following items:<\/p>\n<ul>\n<li>Cougar<\/li>\n<li>Leopard<\/li>\n<li>Lemur<\/li>\n<li>Lion<\/li>\n<li>Llama<\/li>\n<li>Tiger<\/li>\n<\/ul>\n<p>You type L, and this selects <i>Leopard<\/i>, the first animal on the list that begins with L.<\/p>\n<p>You type another L. Since this is now two L&#8217;s, the Win32 ListView is in &#8220;repeated letter&#8221; mode, and it selects the second L-animal, which is <i>Lemur<\/i>.<\/p>\n<p>Now you type A. This is no longer a repeat of the same letter, so the Win32 ListView switches to &#8220;prefix&#8221; mode, and it selects the first item which begins with &#8220;LLA&#8221;, which is <i>Llama<\/i>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Combining prefix search with repeated search, to accommodate multiple styles.<\/p>\n","protected":false},"author":1069,"featured_media":100998,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-109627","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Combining prefix search with repeated search, to accommodate multiple styles.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/109627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=109627"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/109627\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/100998"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=109627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=109627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=109627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}