I have made a own class that derives from the system.forms.form class. Now I want to save this own class in the my.settings collection. That works fine as long as I don't shutdown the program, but as soon as I end the program, this form is lost and the next time I start the application the value is nothing.
So it seems that there is a problem with serializing the form and now I try to use an own TypeConverter class and associate it with the form class. In my typeconverter I overload the function convertToString and convertFromString. And what should happen know is that when the settings get saved, the settings class should call the convertToString function of my own Type Converter (see http://msdn2.microsoft.com/en-us/library/8eyb2ct1(VS.80).aspx).
Here is the code I use:
GetType(AskAnswerConverter))> Class AskAnswer Dim actualword As DataRow Private showExample As EExampleShowings = EExampleShowings.ShowWithAnswer Private UserGaveRightAnswer As Boolean Private _showWordsLeft As Boolean = False 'Some Methods and Properties End Class
Class AskAnswerConverter Inherits System.ComponentModel.TypeConverter Public Overloads Function convertToString(ByVal value As Object) As String If value.GetType Is GetType(AskAnswer) Then Return "successful" Else Return Nothing End If End Function
Public Overloads Function convertFromString(ByVal value As String) As Object Return New AskAnswer() End Function
Public Sub New() MyBase.New() End Sub End Class
What I want to happen now is, that when I load an instance of AskAnswer in the my.settings class and I use the my.settings.save method, an Instance of my AskAnswerConverter is created and used to save the settings. But not even the New Method gets called.