By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

Need help on custom TypeConverter

P: n/a
I am trying to write a TypeConverter for a simple custom class that stores
four boolean properties.

Here is the sample code:

-------------------------------------------

Public Class UserPermissions
Private mCanUserRead As Boolean
Private mCanUserUpdate As Boolean
Private mCanUserAdd As Boolean
Private mCanUserDelete As Boolean
Private mViewID As Long

Public Property CanUserRead() As Boolean
Get
Return mCanUserRead
End Get
Set(ByVal Value As Boolean)
mCanUserRead = Value
End Set
End Property

Public Property CanUserUpdate() As Boolean
Get
Return mCanUserUpdate
End Get
Set(ByVal Value As Boolean)
mCanUserUpdate = Value
End Set
End Property

Public Property CanUserAdd() As Boolean
Get
Return mCanUserAdd
End Get
Set(ByVal Value As Boolean)
mCanUserAdd = Value
End Set
End Property

Public Property CanUserDelete() As Boolean
Get
Return mCanUserDelete
End Get
Set(ByVal Value As Boolean)
mCanUserDelete = Value
End Set
End Property

Public WriteOnly Property ViewID() As Long
Set(ByVal Value As Long)
mViewID = Value
End Set
End Property

Public Sub Load()
....
End Sub
-------------------------------------------

Thanks in advance,

Steve Kallal

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Steve,

What should this TypeConverter do, now it does nothing,

Cor
Nov 21 '05 #2

P: n/a
I should be able to let me store in object in ViewState for ASP .NET. I
cannot do it now because it is not serializable.

"Cor Ligthert" wrote:
Steve,

What should this TypeConverter do, now it does nothing,

Cor

Nov 21 '05 #3

P: n/a
Steve,

Maybe can this sample from Tom help you.

\\\Tom Shelton
Private Function SerializeFontObject(ByVal fnt As Font) As String
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream
Try
bf.Serialize(mem, fnt)
Return Convert.ToBase64String(mem.ToArray())
Catch
Return String.Empty
Finally
mem.Close()
End Try
End Function
Private Function DeserializeFontObject(ByVal fnt As String) As Font
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream(Convert.FromBase64String(fnt))
Try
Return DirectCast(bf.Deserialize(mem), Font)
Finally
If Not mem Is Nothing Then
mem.Close()
End If
End Try
End Function
I hope this helps a little bit?

Cor
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.