239 lines
10 KiB
HTML
239 lines
10 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
<head>
|
||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||
<title>Searching Items</title>
|
||
<link href="style.css" rel="stylesheet" type="text/css">
|
||
<link href="prettify.css" type="text/css" rel="stylesheet">
|
||
<script type="text/javascript" src="prettify.js"></script><script type="text/javascript" src="lang-vb.js"></script><link href="../resources/main.css" media="screen" rel="stylesheet" type="text/css">
|
||
</head>
|
||
<body onload="prettyPrint()"><div class="placing">
|
||
<br><table class="navigation"><tr>
|
||
<td class="navigation-previous"><a href="chapter-save-load.html"><strong>
|
||
« Saving and Loading ListView Content</strong></a></td>
|
||
<td class="navigation-index"><a href="../../../better-thumbnail-browser/documentation.html"><strong>Index</strong></a></td>
|
||
<td class="navigation-next"><a href="chapter-serialization.html"><strong>Serialization »
|
||
</strong></a></td>
|
||
</tr></table>
|
||
<br><h1>Searching Items</h1>
|
||
<div class="banner">
|
||
<a href="../../../better-thumbnail-browser.html"><img src="../resources/better-thumbnail-browser-overview.gif" alt="Better Thumbnail Browser" class="ss"></a>
|
||
<div class="inside">
|
||
<div class="text">Better Thumbnail Browser for .NET (C#, VB) - Image thumbnail viewing and loading control</div>
|
||
<span class="dbtn-c dbtn-hilight"><span class="dbtn-w"><a href="../../../betterthumbnailbrowser.exe" class="dbtn">Download</a></span></span>
|
||
<span class="dbtn-c"><span class="dbtn-w"><a href="../../../better-thumbnail-browser.html" class="dbtn">More Info</a></span></span>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
<p>Better ListView offers many options for searching items by typing on
|
||
keyboard and programmaticaly (<span class="code">FindItemWithText</span>,
|
||
<span class="code">FindItemsWithText</span> methods). Search can be extended to sub-items
|
||
and event multiple items can be contained in a search result.</p>
|
||
|
||
<p>Search can be customized with <span class="code">SearchSettings</span> property.
|
||
This structure contains three other properties:</p>
|
||
|
||
<ul style="list-style:none">
|
||
<li>
|
||
<span class="code">Mode</span><ul style="list-style:none"><li>
|
||
<p>Specifies how the searching is done on each item/sub-item
|
||
string.</p>
|
||
|
||
<ul style="list-style:none">
|
||
<li>
|
||
<span class="code">Disabled</span><ul style="list-style:none"><li>
|
||
<p>Searching is disabled.</p>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">Prefix</span><ul style="list-style:none"><li>
|
||
<p>Search is restricted to text prefix.</p>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">PrefixOrSubstring</span><ul style="list-style:none"><li>
|
||
<p>Search query can match any substring, if nothing found by
|
||
prefix.</p>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">Substring</span><ul style="list-style:none"><li>
|
||
<p>Search query can match any substring.</p>
|
||
</li></ul>
|
||
</li>
|
||
</ul>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">Options</span><ul style="list-style:none"><li>
|
||
<p>Additional options for searching.</p>
|
||
|
||
<ul style="list-style:none">
|
||
<li>
|
||
<span class="code">CaseSensitive</span><ul style="list-style:none"><li>
|
||
<p>The search is case-sensitive.</p>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">FirstWordOnly</span><ul style="list-style:none"><li>
|
||
<p>Search is restricted to the first word of searched
|
||
text.</p>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">None</span><ul style="list-style:none"><li>
|
||
<p>No options active.</p>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">PlaySound</span><ul style="list-style:none"><li>
|
||
<p>Sound is played, when nothing is found.</p>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">PrefixPreference</span><ul style="list-style:none"><li>
|
||
<p>Results matched by prefix are prefered among other (e.g.
|
||
when searching for <strong><em>pla</em></strong>, then the text
|
||
<strong><em>player</em></strong> is prefered among the word
|
||
<strong><em>applause</em></strong>).</p>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">SelectableItemsOnly</span><ul style="list-style:none"><li>
|
||
<p>Restrict the search to selectable items only.</p>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">WordSearch </span><ul style="list-style:none"><li>
|
||
<p>Searched text si first split into words and searching is
|
||
done on each word separately.</p>
|
||
</li></ul>
|
||
</li>
|
||
</ul>
|
||
</li></ul>
|
||
</li>
|
||
<li>
|
||
<span class="code">SubItemIndices</span><ul style="list-style:none"><li>
|
||
<p>Specifies sub-items on which the search is done; if the
|
||
collection is empty, than all sub-items are searched.</p>
|
||
</li></ul>
|
||
</li>
|
||
</ul>
|
||
<p>There is a default one-second delay to register when user stopped
|
||
typing and the search is discarded. A new search is initiated when user
|
||
starts typing after this interval has passed. This interval can be set via
|
||
<span class="code">SearchTimeoutDelay</span> property.</p>
|
||
|
||
<p>The delay is not relevant when user types the same letter several
|
||
times and there are other items beginning with that letter. If there are
|
||
items named <strong><em>ab</em></strong>, <strong><em>ac</em></strong>,
|
||
<strong><em>ad</em></strong>, then the selection cycles through these items as
|
||
long as the user keeps pressing <strong><em>A</em></strong> key. This works
|
||
essentialy the same way as in the Windows Explorer.</p>
|
||
|
||
<br><hr>
|
||
<p class="note">The keyboard search works, of course, only when the control has
|
||
focus. You can ensure this (e.g. when showing the form) by calling
|
||
<span class="code">Focus</span> method on Better ListView.</p>
|
||
<hr>
|
||
<br><h2>Sample Source Code</h2>
|
||
|
||
|
||
<p><strong>C#</strong></p>
|
||
<pre class="prettyprint"><code class="lang-cs">this.listView.BeginUpdate();
|
||
|
||
// fill the ListView with items in two columns
|
||
this.listView.Columns.AddRange(
|
||
new[]
|
||
{
|
||
new BetterListViewColumnHeader("Word", 128),
|
||
new BetterListViewColumnHeader("Synonym List", 160)
|
||
});
|
||
|
||
this.listView.Items.AddRange(
|
||
new[]
|
||
{
|
||
new BetterListViewItem(new[] { "apparently", "evidently, presumably, seemingly" }),
|
||
new BetterListViewItem(new[] { "blunt", "brusque, curt, snippy" }),
|
||
new BetterListViewItem(new[] { "class", "caste, estate, folk" }),
|
||
new BetterListViewItem(new[] { "detailed", "elaborate, full, thorough" }),
|
||
});
|
||
|
||
// search in substrings
|
||
BetterListViewSearchMode searchMode = BetterListViewSearchMode.Substring;
|
||
|
||
// use case-sensitive searching and play sounds
|
||
BetterListViewSearchOptions searchOptions = (BetterListViewSearchOptions.CaseSensitive | BetterListViewSearchOptions.PlaySound);
|
||
|
||
// search in the first and second column
|
||
//NOTE: empty array also means searching in all columns
|
||
int[] subItemIndices = new[] { 0, 1 };
|
||
|
||
// set-up the search
|
||
this.listView.SearchSettings = new BetterListViewSearchSettings(searchMode, searchOptions, subItemIndices);
|
||
|
||
this.listView.EndUpdate();</code></pre>
|
||
|
||
<p><strong>Visual Basic</strong></p>
|
||
<pre class="prettyprint"><code class="lang-vb">ListView.BeginUpdate()
|
||
|
||
' fill the ListView with items in two columns
|
||
ListView.Columns.AddRange(
|
||
New BetterListViewColumnHeader() { _
|
||
New BetterListViewColumnHeader("Word", 128),
|
||
New BetterListViewColumnHeader("Synonym List", 160)
|
||
})
|
||
|
||
ListView.Items.AddRange(
|
||
New BetterListViewItem() { _
|
||
New BetterListViewItem(New String() _
|
||
{"apparently", "evidently, presumably, seemingly"}),
|
||
New BetterListViewItem(New String() {"blunt", "brusque, curt, snippy"}),
|
||
New BetterListViewItem(New String() {"class", "caste, estate, folk"}),
|
||
New BetterListViewItem(New String() {"detailed", "elaborate, full, thorough"})
|
||
})
|
||
|
||
' search in substrings
|
||
Dim searchMode As BetterListViewSearchMode = BetterListViewSearchMode.Substring
|
||
|
||
' use case-sensitive searching and play sounds
|
||
Dim searchOptions As BetterListViewSearchOptions =
|
||
(BetterListViewSearchOptions.CaseSensitive Or BetterListViewSearchOptions.PlaySound)
|
||
|
||
' search in the first and second column
|
||
'NOTE: empty array also means searching in all columns
|
||
Dim subItemIndices As Integer() = New Integer() {0, 1}
|
||
|
||
' set-up the search
|
||
ListView.SearchSettings = New BetterListViewSearchSettings (searchMode, searchOptions, subItemIndices)
|
||
|
||
ListView.EndUpdate()</code></pre>
|
||
|
||
<br><div class="banner">
|
||
<a href="../../../better-thumbnail-browser.html"><img src="../resources/better-thumbnail-browser-overview.gif" alt="Better Thumbnail Browser" class="ss"></a>
|
||
<div class="inside">
|
||
<div class="text">Better Thumbnail Browser for .NET (C#, VB) - Image thumbnail viewing and loading control</div>
|
||
<span class="dbtn-c dbtn-hilight"><span class="dbtn-w"><a href="../../../betterthumbnailbrowser.exe" class="dbtn">Download</a></span></span>
|
||
<span class="dbtn-c"><span class="dbtn-w"><a href="../../../better-thumbnail-browser.html" class="dbtn">More Info</a></span></span>
|
||
</div>
|
||
</div>
|
||
<table class="navigation"><tr>
|
||
<td class="navigation-previous"><a href="chapter-save-load.html"><strong>
|
||
« Saving and Loading ListView Content</strong></a></td>
|
||
<td class="navigation-index"><a href="../../../better-thumbnail-browser/documentation.html"><strong>Index</strong></a></td>
|
||
<td class="navigation-next"><a href="chapter-serialization.html"><strong>Serialization »
|
||
</strong></a></td>
|
||
</tr></table>
|
||
<br><table class="footer"><tr>
|
||
<td class="footer-title">Better Thumbnail Browser Documentation
|
||
</td>
|
||
<td class="footer-copyright">
|
||
Copyright © 2010-2012 <a href="../../../index.html" target="_blank">ComponentOwl.com</a>
|
||
</td>
|
||
</tr></table>
|
||
</div></body>
|
||
</html>
|