151 lines
6.2 KiB
HTML
151 lines
6.2 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>Saving and Loading ListView Content</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-performance.html"><strong>
|
|||
|
|
« Performance</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-search.html"><strong>Searching Items »
|
|||
|
|
</strong></a></td>
|
|||
|
|
</tr></table>
|
|||
|
|
<br><h1>Saving and Loading ListView Content</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 provides methods for storing its content (items with
|
|||
|
|
columns and groups) in a file or stream:</p>
|
|||
|
|
|
|||
|
|
<ul>
|
|||
|
|
<li>
|
|||
|
|
<p><span class="code">SaveContentBinary(string filename)</span></p>
|
|||
|
|
</li>
|
|||
|
|
<li>
|
|||
|
|
<p><span class="code">SaveContentBinary(Stream stream)</span></p>
|
|||
|
|
</li>
|
|||
|
|
<li>
|
|||
|
|
<p><span class="code">SaveContentXml(string filename)</span></p>
|
|||
|
|
</li>
|
|||
|
|
<li>
|
|||
|
|
<p><span class="code">SaveContentXml(XmlWriter writer)</span></p>
|
|||
|
|
</li>
|
|||
|
|
</ul>
|
|||
|
|
<p>Analogically, there are methods to retrieving the stored content
|
|||
|
|
back:</p>
|
|||
|
|
|
|||
|
|
<ul>
|
|||
|
|
<li>
|
|||
|
|
<p><span class="code">LoadContentBinary(string filename)</span></p>
|
|||
|
|
</li>
|
|||
|
|
<li>
|
|||
|
|
<p><span class="code">LoadContentBinary(Stream stream)</span></p>
|
|||
|
|
</li>
|
|||
|
|
<li>
|
|||
|
|
<p><span class="code">LoadContentXml(string filename)</span></p>
|
|||
|
|
</li>
|
|||
|
|
<li>
|
|||
|
|
<p><span class="code">LoadContentXml(XmlReader reader)</span></p>
|
|||
|
|
</li>
|
|||
|
|
</ul>
|
|||
|
|
<p>Storing Better ListView content in a file is very easy. The Following
|
|||
|
|
sample shows storing the content in a binary file:</p>
|
|||
|
|
|
|||
|
|
<p><strong>C#</strong></p>
|
|||
|
|
<pre class="prettyprint"><code class="lang-cs">// save Better ListView items, columns and groups in a XML file
|
|||
|
|
this.listView.SaveContentBinary("listview-content.dat");
|
|||
|
|
|
|||
|
|
// clear content to ensure it is loaded back correctly
|
|||
|
|
this.listView.Clear();
|
|||
|
|
|
|||
|
|
// restore content from file
|
|||
|
|
this.listView.LoadContentBinary("listview-content.dat");</code></pre>
|
|||
|
|
|
|||
|
|
<p><strong>Visual Basic</strong></p>
|
|||
|
|
<pre class="prettyprint"><code class="lang-vb">' save Better ListView items, columns and groups in a XML file
|
|||
|
|
ListView.SaveContentBinary("listview-content.dat")
|
|||
|
|
|
|||
|
|
' clear content to ensure it is loaded back correctly
|
|||
|
|
ListView.Clear()
|
|||
|
|
|
|||
|
|
' restore content from file
|
|||
|
|
ListView.LoadContentBinary("listview-content.dat")</code></pre>
|
|||
|
|
|
|||
|
|
<p>The content can be stored in either binary or XML format. For example,
|
|||
|
|
to store the content in a stream as formatted XML, use the following
|
|||
|
|
code:</p>
|
|||
|
|
|
|||
|
|
<p><strong>C#</strong></p>
|
|||
|
|
<pre class="prettyprint"><code class="lang-cs">XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8);
|
|||
|
|
|
|||
|
|
writer.Formatting = Formatting.Indented;
|
|||
|
|
|
|||
|
|
listView.SaveContentXml(writer);
|
|||
|
|
|
|||
|
|
writer.Close();</code></pre>
|
|||
|
|
|
|||
|
|
<p><strong>Visual Basic</strong></p>
|
|||
|
|
<pre class="prettyprint"><code class="lang-vb">Dim writer As New XmlTextWriter(stream, Encoding.UTF8)
|
|||
|
|
|
|||
|
|
writer.Formatting = Formatting.Indented
|
|||
|
|
|
|||
|
|
listView.SaveContentXml(writer)
|
|||
|
|
|
|||
|
|
writer.Close()</code></pre>
|
|||
|
|
|
|||
|
|
<p>Note that in this case it is necessary to have
|
|||
|
|
<span class="code">XmlTextReader.WhitespaceHandling</span> property set to
|
|||
|
|
<span class="code">None</span> when loading content from formatted XML stream because
|
|||
|
|
white spaces need to be skipped during the deserialization process.</p>
|
|||
|
|
|
|||
|
|
<p>Standard <strong><em><a href="chapter-serialization.html">Serialization</a></em></strong> mechanisms are
|
|||
|
|
used to store elements and its properties. The methods named above store
|
|||
|
|
also mapping between items and their corresponding groups. This cannot be
|
|||
|
|
done when simply serializing <span class="code">Groups</span> or <span class="code">Items</span>
|
|||
|
|
collection.</p>
|
|||
|
|
|
|||
|
|
<br><hr>
|
|||
|
|
<p class="note">When content is loaded into Better ListView, the current content is
|
|||
|
|
cleared.</p>
|
|||
|
|
<hr>
|
|||
|
|
<br><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-performance.html"><strong>
|
|||
|
|
« Performance</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-search.html"><strong>Searching Items »
|
|||
|
|
</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>
|