all groups > dotnet windows forms designtime > october 2005 >
You're in the

dotnet windows forms designtime

group:

ShouldSerialize question


ShouldSerialize question Carlo
10/18/2005 12:00:00 AM
dotnet windows forms designtime:
Hi all,

In my Form1, I have this statement:

Me.EnhancedPanelGreen2.Background.Color =
System.Drawing.Color.GreenYellow

This is normal, because I've set to GreenYellow the Color property of the
class Background in the component EnhancedPanelGreen2.
Now, the following is the part of code of the class Background inside
EnhancedPanelGreen2 component that controls the serialization:

Public Property Color() As Color
Get
Return mColor
End Get
Set(ByVal value As Color)
mColor = value
End Set
End Property
' <Serialization>
Protected Sub ResetColor()
Color = Color.Green
End Sub
Protected Function ShouldSerializeColor() As Boolean
Return Not Color.Equals(Color.Green)
End Function

The problem is that changing Color to Green (that is the default of Color
property) in the property browser of Form1, the statement inside my Form1 IS
STILL:

Me.EnhancedPanelGreen2.Background.Color =
System.Drawing.Color.GreenYellow

What I need (and what I expected) is that the above statement will
disappears because the color (Green) is equal to the default(Green). Could
someone try to explain me what I'm missing?

Thank you very much

Carlo




Re: ShouldSerialize question Carlo
10/18/2005 12:00:00 AM
Hi Kalpesh
this is not the case. I've changed Color Property to Green from within the
Property Window of the IDE. I simply expected that the statement with the
new color (Green) will disappears.
I've studied the problem from all the sides, finding no solutions




-------------------------------------------
Carlo, MCP (Windows Based Applications)
carlodevREMOVE@gmail.com


"Kalpesh" <shahkalpesh@gmail.com> ha scritto nel messaggio
news:1129634321.816839.13740@g44g2000cwa.googlegroups.com...
[quoted text, click to view]

Re: ShouldSerialize question Carlo
10/18/2005 12:00:00 AM
Hi Kalpesh
the only problem is that the line

Me.EnhancedPanelGreen2.Background.Color = System.Drawing.Color.GreenYellow

is NOT removed by the designer when the color is set to Green.

Using the debugger not helped me to discover why.
If you have two or three minutes of patience, I can send you a very small
project that illustrates the problem.
Carlo




-------------------------------------------
Carlo, MCP (Windows Based Applications)
carlodevREMOVE@gmail.com


"Kalpesh" <shahkalpesh@gmail.com> ha scritto nel messaggio
news:1129643839.505962.300900@g47g2000cwa.googlegroups.com...
[quoted text, click to view]

Re: ShouldSerialize question Kalpesh
10/18/2005 4:18:41 AM
Hi Carlo,

I dont know - how does it relate to ShouldSerialize ?
Moreover, if you change any of the property of any control, the VS.NET
ide will generate code & put it in some specific location. e.g.
"InitializeComponent"

So, if you have hand-coded anything specific, it will not be replaced
by what you set from the properties window

Is that the case here ?

Kalpesh
Re: ShouldSerialize question Kalpesh
10/18/2005 6:57:19 AM
Hi Carlo,

Are you able to change the color using the property window ?
Before running the app, put a watch on whenever Color property changes.
This will help you identify - what is it that is resetting the color &
not taking your value at all

HTH
Kalpesh
AddThis Social Bookmark Button