User control problem

  • Thread starter Thread starter Som sally
  • Start date Start date
S

Som sally

I'm writing a windows user control in C# and 'm not able to retain the
change made to the usercontrol public properties.

If i drop the user control in the designer, change it's property values
and run the program the properties are reverting to the default values.

In VB6 there was a convenient way of storing values in PropertyBag
collection and accessing via ReadProperties or WriteProperties.

I searched in web and found that the suggestion was to use
Serialization. Is there any other way?
 
Simple properties such as integers and strings should be serialized to code
automatically by the designer. Complex properties such as collections will
require the use of the designerserializationvisibility attribute to ensure
that the designer knows how to serialize them.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
I'm new to C#(VB6 background). so forgive me if i'm asking something
wrong.

My user control has a textbox and a label control. Now i want to provide
a backcolor property which would allow me to change the backcolor of the
textbox. Since user control also contains a backcolor i had to override
the property like this:

public override Color BackColor
{
get
{
return textBox1.BackColor;
}
set
{
textBox1.BackColor = value;
}
}

however when i'm using the control in the client app the designer
doesnot persist the changes i made to this backcolor property.
 
Back
Top