473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Serializing ListViewItem.Tag C#

Hi,

I've written a small piece of code that serializes my ListView with all
it's ListViewItems, but for some reason it doesn't seem to serialize
the ListViewItem.Tag (custom IDictionary class) properties.

Anyone know why this could be the case?

Thanks in advance,
Eirik

Jul 11 '06 #1
3 3415
hauke,

Is the custom IDictionary class serializable?
--
Stoitcho Goutsev (100)

"hauke" <ei************@gmail.comwrote in message
news:11**********************@35g2000cwc.googlegro ups.com...
Hi,

I've written a small piece of code that serializes my ListView with all
it's ListViewItems, but for some reason it doesn't seem to serialize
the ListViewItem.Tag (custom IDictionary class) properties.

Anyone know why this could be the case?

Thanks in advance,
Eirik

Jul 11 '06 #2
Hi Hauke,

ListViewItem performs its own serialization by implementing the
ISerializable interface (I looked at the class in the 2.0 framework). For
this reason the class may just omit the Tag property during serialization
since Tag is System.Object and usually holds very specific information
within a particular context that will probably be lost after
deserialization. You could create a ListViewItemWrapper class that
implements ISerializable as well, forwarding calls for serialization and
deserialization to the underlying ListViewItem instance and add as many
custom serialization properties as you'd like to the wrapper class. This is
a better approach than using Tag for serialization.

HTH

"hauke" <ei************@gmail.comwrote in message
news:11**********************@35g2000cwc.googlegro ups.com...
Hi,

I've written a small piece of code that serializes my ListView with all
it's ListViewItems, but for some reason it doesn't seem to serialize
the ListViewItem.Tag (custom IDictionary class) properties.

Anyone know why this could be the case?

Thanks in advance,
Eirik

Jul 11 '06 #3
Hi,

Thanks for your replies.

Yes, It seems like it doesn't serialize the .Tag property so I followed
your advice and made a wrapper class.

Thanks,
Eirik

Dave Sexton skrev:
Hi Hauke,

ListViewItem performs its own serialization by implementing the
ISerializable interface (I looked at the class in the 2.0 framework). For
this reason the class may just omit the Tag property during serialization
since Tag is System.Object and usually holds very specific information
within a particular context that will probably be lost after
deserialization. You could create a ListViewItemWrapper class that
implements ISerializable as well, forwarding calls for serialization and
deserialization to the underlying ListViewItem instance and add as many
custom serialization properties as you'd like to the wrapper class. This is
a better approach than using Tag for serialization.

HTH

"hauke" <ei************@gmail.comwrote in message
news:11**********************@35g2000cwc.googlegro ups.com...
Hi,

I've written a small piece of code that serializes my ListView with all
it's ListViewItems, but for some reason it doesn't seem to serialize
the ListViewItem.Tag (custom IDictionary class) properties.

Anyone know why this could be the case?

Thanks in advance,
Eirik
Jul 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: LV | last post by:
Hello, I would like to manually set one of my list view items as selected. When this item is set, I would like for a method to execute. I have a delegate on the list view for SelectedIndexChanged....
0
by: afatdog | last post by:
I want to change the ListViewItem's StateImageIndex to change. private void Button_xx_Click(object sender, System.EventArgs e) { ListViewItem.StateImageIndex++; } But the ListViewItem's...
6
by: grs | last post by:
The following is a code example from the Microsoft MSDN. My question is on the following three lines of code: ListViewItem item1 = new ListViewItem("item1",0); ListViewItem item2 = new...
0
by: Kluch | last post by:
I am trying to select and focus single ListViewItem and can't seem to do so, here is my code: IEnumerator * itemList = mLsvMyList->Items->GetEnumerator(); while (itemList->MoveNext()) {...
1
by: Alan T | last post by:
I have a listview defined a coloumn at design time. And the code I use to add a listviewitem: ListViewItem lvi = new ListViewItem(user.Name); lvi.Tag = (Object)user.Id; ...
2
by: Kela | last post by:
An interesting problem: I have a ListView with LabelEdit set to TRUE. When I change the label, I want to make some decisions as to whether the ListViewItem (that's just been edited) should stay in...
0
by: garyusenet | last post by:
I am trying to create a form that will display a list of open internet explorer windows and allow the user to choose one of them. So far I have created an arraylist which contains all of the open...
13
by: deciacco | last post by:
How can I have access to the items collection of a listview control on my form from a background thread? I know I need delegates to update the listview control and I have those calls in the...
10
by: Gav | last post by:
I am trying to have a ListView to dispay a list of names and want to have an id stored within the list but not visable. I have tried to go about doing this by using the ListViewItem and setting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.