Hi,
We have a prob with .Net User Controls, something like this. I have a
Custon Control InfoLabel Derived from System.Windows. Forms.Label ( Direct
Inheritance - Custom Control) and the some properties of this is held in one
custon Class.
By setting TypeConverter attribute to the above class we could make it the
subproperty. AS a singale control its working fine.
Now, We have created another User Control, InfoMultiLabel, that uses this
control (Not inheriting but simply 2 contols of earlier one - the
InfoLabel). These two InfoLables are exposed as sub properties so that its
properties can be set differently for each (eg one balck and another blue).
OK we could set the properties at design time. But the propb is its value
not Getting serialed and hence when after closing the forn and reopening the
already set values are removed. (design time property no persisiting once
closed and re opened).
Any idea abt this. What attribute should be given to make this property
persisitng? Can it be done?. I have duplicated the prob with a small code,
given below. Any help is highly appreciated.
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Drawing;
using System.Data;
using System.Windows. Forms;
namespace Test
{
public class Test : System.Windows. Forms.UserContr ol
{
private System.Windows. Forms.Label label1;
private System.Componen tModel.Containe r components = null;
public Test()
{
InitializeCompo nent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
private void InitializeCompo nent()
{
this.label1 = new System.Windows. Forms.Label();
this.SuspendLay out();
//
// label1
//
this.label1.Bor derStyle = System.Windows. Forms.BorderSty le.FixedSingle;
this.label1.Loc ation = new System.Drawing. Point(48, 16);
this.label1.Nam e = "label1";
this.label1.Tab Index = 0;
this.label1.Tex t = "label1";
//
// Test
//
this.Controls.A dd(this.label1) ;
this.Name = "Test";
this.Size = new System.Drawing. Size(184, 64);
this.Load += new System.EventHan dler(this.Test_ Load);
this.ResumeLayo ut(false);
}
#endregion
private void Test_Load(objec t sender, System.EventArg s e)
{
}
/// <summary>
/// Property for setting the ForeColor
/// </summary>
[Category( "Controls" )]
[Description( "Property for setting the InfoLabel Control" )]
[DefaultValue( typeof(Label)," Label" )]
[DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content)]
public Label InfoLabel // <<<<<<<<------ NOT Serializing this Value
{
get { return label1; }
set
{
label1 = value;
}
}
}
}