NV2002
December 28th, 2002, 02:17 PM
Object Serialization
Is is possible to Take all of the ITEMS out of a LISTVIEW
and serialize them and save them to a DISK file ?
I have tried to CLONE each Item in a Listview. While
that works it will not Get the Column Headers or
checkmarks if enabled.
Trial Code Used
Dim LviClone() As ListViewItem
Public Sub SaveClone()
Dim i As Integer
' Make a Clone of the Listview Items
If ListView1.Items.Count > 0 Then
ReDim LviClone(ListView1.Items.Count - 1) ' Dim Storage
' Clone the Items one by one
For i = 0 To (ListView1.Items.Count - 1)
LviClone(i) = ListView1.Items.Item(i).Clone()
Next i
End If
End Sub
Public Sub RestoreClone()
' Take it from the MASTER Structure
LviClone = SysSave.lviArray
Dim i As Integer
' Restore a Clone of the Listview
' Make Headers
InitLV(ListView1) ' Master Column Maker
Try
ListView1.Items.AddRange(LviClone)
Catch
StatusBar1.Text = "Nothing to Restore"
End Try
End Sub
This will not Save Column Headers or the Boolean Checkmarks if enabled.
The Column Headers are marked as NOT Serializable so I can't use
the same method.
Is there any way to SAVE the ENTIRE LISTVIEW to disk by serializing
the OBJECT ?
How else can this be done ?
Thanks,
Nick
Is is possible to Take all of the ITEMS out of a LISTVIEW
and serialize them and save them to a DISK file ?
I have tried to CLONE each Item in a Listview. While
that works it will not Get the Column Headers or
checkmarks if enabled.
Trial Code Used
Dim LviClone() As ListViewItem
Public Sub SaveClone()
Dim i As Integer
' Make a Clone of the Listview Items
If ListView1.Items.Count > 0 Then
ReDim LviClone(ListView1.Items.Count - 1) ' Dim Storage
' Clone the Items one by one
For i = 0 To (ListView1.Items.Count - 1)
LviClone(i) = ListView1.Items.Item(i).Clone()
Next i
End If
End Sub
Public Sub RestoreClone()
' Take it from the MASTER Structure
LviClone = SysSave.lviArray
Dim i As Integer
' Restore a Clone of the Listview
' Make Headers
InitLV(ListView1) ' Master Column Maker
Try
ListView1.Items.AddRange(LviClone)
Catch
StatusBar1.Text = "Nothing to Restore"
End Try
End Sub
This will not Save Column Headers or the Boolean Checkmarks if enabled.
The Column Headers are marked as NOT Serializable so I can't use
the same method.
Is there any way to SAVE the ENTIRE LISTVIEW to disk by serializing
the OBJECT ?
How else can this be done ?
Thanks,
Nick