0

I have an object such as the following

Public Class Item
    Public Property Description As String
    <XmlIgnore>
    Public Property Picture As Bitmap = My.Resources.no_image

    <XmlElement(ElementName:="Picture")>
    <Browsable(False)>
    Public Property _pic As String
       Get
           Return ImageToString(Me.Picture)
       End Get

       Set
           Picture = StringToImage(Value)
       End Set
    End Property

    Public Property Location As String
    Public Property Price As Single
    Public Property Status As String
End Class

This object is intended to be displayed in a DataGridView within winforms, but I would like to also be able to serialze it to XML, using XmlSerializer. I have implemented two functions that convert a bitmap to a base64 string and back.

Where I ran in to trouble is coming up with a way to alter the serilazation process of the Bitmap class, as it is not inheritable, and the above solution has not achieved the desired result.

How would I go about fixing this?

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Zeludon
  • 45
  • 2
  • 5
  • https://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable(v=vs.110).aspx – Hans Passant Jul 28 '18 at 08:23
  • Yes, I have read that previously, but the example is vague, in c#, and would require me to have to write my own code for all properties. I would like to know a way to alter just one properties serialzation method. I have attempted to make a class that implements IXmlSerializable and inherits Bitmap but Bitmap is not inheritable. – Zeludon Jul 28 '18 at 08:33
  • 1
    https://stackoverflow.com/q/1907077/3110834 – Reza Aghaei Jul 28 '18 at 09:03
  • 1
    Thanks!, wish I could have found that thread eariler. – Zeludon Jul 28 '18 at 09:26
  • Please note that VBA is *NOT* equivalent to VB.NET - it's totally different! Please be careful when tagging your questions. Correct tagging will also help you get better help, faster. – Cindy Meister Jul 29 '18 at 15:42

0 Answers0