Hi,
I have a user control and I want an array of items to be available to
the user
In my case these items are a class called Needle.
I added a property called Needles to get\set the array (Needle[]) and
it seems to work except that the designer doesn't handle it correctly
In the property page of the designer I see the property and I can
click on it and I get a property window and I can add new Needles.
These are thrown away, they never make it to the cs file and I don't
know why.
The will remain in the design property page until I close VS or
compile.
I have put the code in the Form_Load() to set the array and it works
but the property page does nothing
The code is below, {1} is where I would expect the designer to have
inserted code (similar to {2}) to create the objects.
Anyone have any idea what is wrong?
Vin
/// <summary>
/// Form Code
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private QuickTest.MultiNeedleSlider multiNeedleSlider1;
private void InitializeComponent()
{
//
// multiNeedleSlider1
//
this.multiNeedleSlider1.Location = new System.Drawing.Point(48,
24);
this.multiNeedleSlider1.Name = "multiNeedleSlider1";
this.multiNeedleSlider1.Size = new System.Drawing.Size(312, 72);
this.multiNeedleSlider1.TabIndex = 3;
// {1} would expect the Needles to be new'd here!
}
private void Form1_Load(object sender, System.EventArgs e)
{
// {2} This works perfectly
QuickTest.MultiNeedleSlider.Needle nn = new
QuickTest.MultiNeedleSlider.Needle();
nn.Color = Color.Red;
multiNeedleSlider1.Needles = new
QuickTest.MultiNeedleSlider.Needle[1] {nn};
}
}
//////////////////////////////////////////////////
/// <summary>
/// User Control Code
/// </summary>
public class MultiNeedleSlider : System.Windows.Forms.UserControl
{
private Needle[] m_aNeedles;
public Needle[] Needles
{
get
{
return m_aNeedles;
}
set
{
m_aNeedles = value;
}
}
// begin class Needle
public class Needle
{
private System.Drawing.Color m_colour;
public Needle()
{
m_colour = Color.Black;
}
public System.Drawing.Color Color
{
get
{
return m_colour;
}
set
{
m_colour = value;
}
}
} // end class Needle
}