From: Mr. X. on
I need a way for saving the panel and all of it's component to a file.
I understand that Panel is not serializable, but I didn't find any trick to
make it be one.
I read the article you gave, but didn't find any way for saving the panel.

Also did :
dim prs() As System.Reflection.PropertyInfo
Dim cc
....
dim myPanel as Panel
....
For i = 0 To MyPanel.Controls.Count - 1
prs = MyPanel.controls(i).GetType().GetProperties()
For j = 0 To prs.Count - 1
If prs(j).CanRead AndAlso prs(j).CanWrite() Then
cc = prs(j).GetValue(c.ActiveControl, Nothing) '
*****
end if
next j
next I

The inner loop (with the asterisks) doesn't retrieve the properties exactly
as I retrieve on design time (property window).
I don't need something too much complicated - just to translate to a stream,
that can store on a database.

Thanks :)

"Onur G�zel" <kimiraikkonen85(a)gmail.com> wrote in message
news:a49c795c-1806-47ae-a041-26b46ff77922(a)q12g2000yqj.googlegroups.com...
> On Jun 20, 10:22 am, "Mr. X." <nospam(a)nospam_please.com> wrote:
>> I would like to learn more about serialization.
>> The code I did is :
>> Dim f As System.IO.FileStream
>> Dim binFormat As New BinaryFormatter
>>
>> f = nothing
>> try
>> f = New FileStream("items.txt", FileMode.Create)
>>
>> binFormat.Serialize(f, MyPanel)
>> finally
>> f.close()
>> end try
>>
>> MyPanel is declared as Panel. (dim myPanel as Panel ...)
>> Even I create myPanel as this :
>> Public Class MyPanelClass
>> Inherits Panel
>> Implements ISerializable
>>
>> Public Sub GetObjectData(ByVal info As
>> System.Runtime.Serialization.SerializationInfo, ByVal context As
>> System.Runtime.Serialization.StreamingContext) Implements
>> System.Runtime.Serialization.ISerializable.GetObjectData
>> Dim i As Integer
>> i = 1 ' this code is not reachable **** what should I write
>> here. need an example, please ***********************
>> End Sub
>> End Class
>>
>> ...
>> dim myPanel as MyPanelClass
>> ...
>>
>> I need a simple sample (specifically : saving panel & objects on it).
>>
>> Thanks :)
>>
>> "Onur G�zel" <kimiraikkone...(a)gmail.com> wrote in message
>>
>> news:99a7b09b-d1ad-4e76-91bd-b729d564bbfa(a)d37g2000yqm.googlegroups.com...
>>
>> > On Jun 16, 2:56 pm, "Mr. X." <nospam(a)nospam_please.com> wrote:
>> >> Hello.
>> >> Is there any way to save a control + all of it's components to a file
>> >> (or
>> >> give it some representation as a long string).
>>
>> >> Thanks :)
>>
>> > Maybe you're looking at object serialization to save a serializable
>> > object on the disk. This search may lead you to start:
>>
>> >http://www.google.com/search?hl=en&client=firefox-a&hs=5Ad&rls=org.mo...
>>
>> > HTH,
>>
>> > Onur G�zel
>
> Well, you serialize classes which are marked with "<Serialiable()>"
> attribute such as arrays and strings, in that case the panel base
> class doesn't seem to have this attribute and thus its members cannot
> be serialized, and you'll get SerializationException error.
>
> http://msdn.microsoft.com/en-us/library/system.windows.forms.panel.aspx
>
> If your own class or any .NET class had this attribute, you could
> easily have serialized and deserialized its fields/members like in the
> followings:
>
> http://devcity.net/Articles/113/1/dotnet_serialization.aspx
> http://devcity.net/Articles/113/1/dotnet_serialization.aspx
> http://www.java2s.com/Tutorial/VB/0240__Stream-File/0480__Binary-Serialization.htm
>
>
> HTH,
>
> Onur G�zel

From: Mr. X. on
In other words, is how can I serialize a panel.
If this cannot be done, so how can I search all of its properties exactly as
they are seen on the property editor ?
Thank :)

"Mr. X." <nospam(a)nospam_please.com> wrote in message
news:efB8NbIELHA.4824(a)TK2MSFTNGP05.phx.gbl...
> I need a way for saving the panel and all of it's component to a file.
> I understand that Panel is not serializable, but I didn't find any trick
> to make it be one.
> I read the article you gave, but didn't find any way for saving the panel.
>
> Also did :
> dim prs() As System.Reflection.PropertyInfo
> Dim cc
> ...
> dim myPanel as Panel
> ...
> For i = 0 To MyPanel.Controls.Count - 1
> prs = MyPanel.controls(i).GetType().GetProperties()
> For j = 0 To prs.Count - 1
> If prs(j).CanRead AndAlso prs(j).CanWrite() Then
> cc = prs(j).GetValue(c.ActiveControl, Nothing)
> ' *****
> end if
> next j
> next I
>
> The inner loop (with the asterisks) doesn't retrieve the properties
> exactly as I retrieve on design time (property window).
> I don't need something too much complicated - just to translate to a
> stream, that can store on a database.
>
> Thanks :)
>
> "Onur G�zel" <kimiraikkonen85(a)gmail.com> wrote in message
> news:a49c795c-1806-47ae-a041-26b46ff77922(a)q12g2000yqj.googlegroups.com...
>> On Jun 20, 10:22 am, "Mr. X." <nospam(a)nospam_please.com> wrote:
>>> I would like to learn more about serialization.
>>> The code I did is :
>>> Dim f As System.IO.FileStream
>>> Dim binFormat As New BinaryFormatter
>>>
>>> f = nothing
>>> try
>>> f = New FileStream("items.txt", FileMode.Create)
>>>
>>> binFormat.Serialize(f, MyPanel)
>>> finally
>>> f.close()
>>> end try
>>>
>>> MyPanel is declared as Panel. (dim myPanel as Panel ...)
>>> Even I create myPanel as this :
>>> Public Class MyPanelClass
>>> Inherits Panel
>>> Implements ISerializable
>>>
>>> Public Sub GetObjectData(ByVal info As
>>> System.Runtime.Serialization.SerializationInfo, ByVal context As
>>> System.Runtime.Serialization.StreamingContext) Implements
>>> System.Runtime.Serialization.ISerializable.GetObjectData
>>> Dim i As Integer
>>> i = 1 ' this code is not reachable **** what should I write
>>> here. need an example, please ***********************
>>> End Sub
>>> End Class
>>>
>>> ...
>>> dim myPanel as MyPanelClass
>>> ...
>>>
>>> I need a simple sample (specifically : saving panel & objects on it).
>>>
>>> Thanks :)
>>>
>>> "Onur G�zel" <kimiraikkone...(a)gmail.com> wrote in message
>>>
>>> news:99a7b09b-d1ad-4e76-91bd-b729d564bbfa(a)d37g2000yqm.googlegroups.com...
>>>
>>> > On Jun 16, 2:56 pm, "Mr. X." <nospam(a)nospam_please.com> wrote:
>>> >> Hello.
>>> >> Is there any way to save a control + all of it's components to a file
>>> >> (or
>>> >> give it some representation as a long string).
>>>
>>> >> Thanks :)
>>>
>>> > Maybe you're looking at object serialization to save a serializable
>>> > object on the disk. This search may lead you to start:
>>>
>>> >http://www.google.com/search?hl=en&client=firefox-a&hs=5Ad&rls=org.mo...
>>>
>>> > HTH,
>>>
>>> > Onur G�zel
>>
>> Well, you serialize classes which are marked with "<Serialiable()>"
>> attribute such as arrays and strings, in that case the panel base
>> class doesn't seem to have this attribute and thus its members cannot
>> be serialized, and you'll get SerializationException error.
>>
>> http://msdn.microsoft.com/en-us/library/system.windows.forms.panel.aspx
>>
>> If your own class or any .NET class had this attribute, you could
>> easily have serialized and deserialized its fields/members like in the
>> followings:
>>
>> http://devcity.net/Articles/113/1/dotnet_serialization.aspx
>> http://devcity.net/Articles/113/1/dotnet_serialization.aspx
>> http://www.java2s.com/Tutorial/VB/0240__Stream-File/0480__Binary-Serialization.htm
>>
>>
>> HTH,
>>
>> Onur G�zel
>