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.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Test
{
public class Test : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Label label1;
private System.ComponentModel.Container components = null;
public Test()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label1.Location = new System.Drawing.Point(48, 16);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// Test
//
this.Controls.Add(this.label1);
this.Name = "Test";
this.Size = new System.Drawing.Size(184, 64);
this.Load += new System.EventHandler(this.Test_Load);
this.ResumeLayout(false);
}
#endregion
private void Test_Load(object sender, System.EventArgs e)
{
}
/// <summary>
/// Property for setting the ForeColor
/// </summary>
[Category( "Controls" )]
[Description( "Property for setting the InfoLabel Control" )]
[DefaultValue( typeof(Label),"Label" )]
[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]
public Label InfoLabel // <<<<<<<<------ NOT Serializing this Value
{
get { return label1; }
set
{
label1 = value;
}
}
}
}