# Serialization

Better ListView: Ultimate .NET ListView replacement control for WinForms (C#, VB.NET)
Download More Info

All Better ListView elements, element collections and some support structures can be both binary and XML serialized. These classes implement ISerializable and IXmlSerializable interfaces. They are also marked by SerializableAttribute.

Serializable element classes are:

- BetterListViewColumnHeader

- BetterListViewGroup

- BetterListViewItem

Serializable element collections are:

- BetterListViewColumnHeaderCollection

- BetterListViewGroupCollection

- BetterListViewItemCollection

- BetterListViewSubItemCollection

Serializable support structures are:

- BetterListViewAddress (ToString and Parse methods can be also used instead of serialization)

- BetterListViewInsertionLocation (see Insertion Mark)

- BetterListViewItemDragData (see Drag and Drop)

- BetterListViewSortList (see Sorting Items)

- BetterListViewToolTipInfo

- BetterListViewToolTipInfoCollection

## Comparing Elements and Collection by Value

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 EqualsContent method.

When using EqualsContent 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 Equals ro ReferenceEquals):

C#

    // 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

Visual Basic

    ' 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

When using EqualsContent 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 EqualsContent on each collection element.

Better ListView: Ultimate .NET ListView replacement control for WinForms (C#, VB.NET)
Download More Info