Custom control collection property problem
I have a custom control that inherits from UserControl. I also have a strong typed ArrayList, I only have .NET 1.1 so no generic lists, of another class I made. When I try and edit the property with the form editor it appears everything works. I can add items, close out, go back in and they're still there. The problem is that the form designer doesn't add any code to add the entries to the property.
Here's my strong typed ArrayList:
public class TickArray : CollectionBase
{
public TickCutoff this[int index]
{
get { return (TickCutoff)InnerList[index]; }
set { InnerList[index] = value; }
}
public TickArray()
{
}
public int Add(TickCutoff tc)
{
return InnerList.Add(tc);
}
public int IndexOf(TickCutoff tc)
{
return InnerList.IndexOf(tc);
}
public void Insert(int index, TickCutoff tc)
{
InnerList.Insert(index, tc);
}
public void Remove(TickCutoff tc)
{
InnerList.Remove(tc);
}
public bool Contains(TickCutoff tc)
{
return InnerList.Contains(tc);
}
}
The class the class above stores
public struct TickCutoff
{
#region Fields
private int d_cutoff;
private int d_numMinorTicks;
#endregion
#region Properties
public int cutoff
{
get { return d_cutoff; }
set { d_cutoff = value; }
}
public int numMinorTicks
{
get { return d_numMinorTicks; }
set { d_numMinorTicks = value; }
}
#endregion
#region Public Methods
public TickCutoff(int Cutoff, int NumMinorTicks)
{
d_cutoff = Cutoff;
d_numMinorTicks = NumMinorTicks;
}
#endregion
}
Here's the relevant property
public TickArray tickZoomCutoffs
{
get
{
if(d_tickZoomCutoffs == null)
d_tickZoomCutoffs = new TickArray();
return d_tickZoomCutoffs;
}
set
{ d_tickZoomCutoffs = value; }
}