Files

160 lines
6.9 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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>Serialization</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-search.html"><strong>
« Searching Items</strong></a></td>
<td class="navigation-index"><a href="../../../quick-start-guide/better-listview/index.html"><strong>Index</strong></a></td>
<td class="navigation-next"><a href="chapter-sort.html"><strong>Sorting Items »
</strong></a></td>
</tr></table>
<br><h1>Serialization</h1>
<div class="banner">
<a href="../../../blog/page/6/index.html"><img src="../resources/overview.gif" alt="Better ListView" class="ss"></a>
<div class="inside">
<div class="text">Better ListView: Ultimate .NET ListView replacement control for WinForms (C#, VB.NET)</div>
<span class="dbtn-c dbtn-hilight"><span class="dbtn-w"><a href="../../../betterlistview.exe" class="dbtn">Download</a></span></span>
<span class="dbtn-c"><span class="dbtn-w"><a href="../../../blog/page/6/index.html" class="dbtn">More Info</a></span></span>
</div>
</div>
<p>All Better ListView elements, element collections and some support
structures can be both <strong><em>binary</em></strong> and <strong><em>XML
serialized</em></strong>. These classes implement <span class="code">ISerializable</span>
and <span class="code">IXmlSerializable</span> interfaces. They are also marked by
<span class="code">SerializableAttribute</span>.</p>
<p>Serializable element classes are:</p>
<ul>
<li>
<p><span class="code">BetterListViewColumnHeader</span></p>
</li>
<li>
<p><span class="code">BetterListViewGroup</span></p>
</li>
<li>
<p><span class="code">BetterListViewItem</span></p>
</li>
</ul>
<p>Serializable element collections are:</p>
<ul>
<li>
<p><span class="code">BetterListViewColumnHeaderCollection</span></p>
</li>
<li>
<p><span class="code">BetterListViewGroupCollection</span></p>
</li>
<li>
<p><span class="code">BetterListViewItemCollection</span></p>
</li>
<li>
<p><span class="code">BetterListViewSubItemCollection</span></p>
</li>
</ul>
<p>Serializable support structures are:</p>
<ul>
<li>
<p><span class="code">BetterListViewAddress</span> (<span class="code">ToString</span> and
<span class="code">Parse</span> methods can be also used instead of
serialization)</p>
</li>
<li>
<p><span class="code">BetterListViewInsertionLocation</span> (see <strong><em><a href="chapter-insertion-mark.html">Insertion Mark</a></em></strong>)</p>
</li>
<li>
<p><span class="code">BetterListViewItemDragData</span> (see <strong><em><a href="chapter-drag-drop.html">Drag and Drop</a></em></strong>)</p>
</li>
<li>
<p><span class="code">BetterListViewSortList</span> (see <strong><em><a href="chapter-sort.html">Sorting Items</a></em></strong>)</p>
</li>
<li>
<p><span class="code">BetterListViewToolTipInfo</span></p>
</li>
<li>
<p><span class="code">BetterListViewToolTipInfoCollection</span></p>
</li>
</ul>
<h2>Comparing Elements and Collection by Value</h2>
<p>When you need to check whether two objects from Better ListView
(namely elements or collections) are same, you can serialize them and
compare the serialized data. More efficient way to do the same is to call
<span class="code">EqualsContent</span> method.</p>
<p>When using <span class="code">EqualsContent</span> on element instances, this
method checks whether the two elements have same text, font, color...
rather than whether there are the same instance (as happens with
<span class="code">Equals</span> ro <span class="code">ReferenceEquals</span>):</p>
<p><strong>C#</strong></p>
<pre class="prettyprint"><code class="lang-cs">// create some item
BetterListViewItem item1 = new BetterListViewItem("new iem");
// create second item as a clone of the first
BetterListViewItem item2 = (BetterListViewItem)item1.Clone();
// check whether item1 and item2 are different instances
item1.Equals(item2); // returns false
// check whether item1 and item2 have properties with the same values
item1.EqualsContent(item2); // returns true</code></pre>
<p><strong>Visual Basic</strong></p>
<pre class="prettyprint"><code class="lang-vb">' create some item
Dim item1 As New BetterListViewItem("new iem")
' create second item as a clone of the first
Dim item2 As BetterListViewItem = DirectCast(item1.Clone(), BetterListViewItem)
' check whether item1 and item2 are different instances
item1.Equals(item2) ' returns false
' check whether item1 and item2 have properties with the same values
item1.EqualsContent(item2) ' returns true</code></pre>
<br><hr>
<p class="note">When using <span class="code">EqualsContent</span> on collection instances,
this method check whether both collections contain the same instances of
collection items. It does not compare collection items by content. To do
this, you still need to iterate both collections and call
<span class="code">EqualsContent</span> on each collection element.</p>
<hr>
<br><br><div class="banner">
<a href="../../../blog/page/6/index.html"><img src="../resources/overview.gif" alt="Better ListView" class="ss"></a>
<div class="inside">
<div class="text">Better ListView: Ultimate .NET ListView replacement control for WinForms (C#, VB.NET)</div>
<span class="dbtn-c dbtn-hilight"><span class="dbtn-w"><a href="../../../betterlistview.exe" class="dbtn">Download</a></span></span>
<span class="dbtn-c"><span class="dbtn-w"><a href="../../../blog/page/6/index.html" class="dbtn">More Info</a></span></span>
</div>
</div>
<table class="navigation"><tr>
<td class="navigation-previous"><a href="chapter-search.html"><strong>
« Searching Items</strong></a></td>
<td class="navigation-index"><a href="../../../quick-start-guide/better-listview/index.html"><strong>Index</strong></a></td>
<td class="navigation-next"><a href="chapter-sort.html"><strong>Sorting Items »
</strong></a></td>
</tr></table>
<br><table class="footer"><tr>
<td class="footer-title">Better ListView Documentation
</td>
<td class="footer-copyright">
Copyright © 2010-2012  <a href="../../../index.html" target="_blank">ComponentOwl.com</a>
</td>
</tr></table>
</div></body>
</html>