Collection Editor Problem
-
i have made one double type collection editor in web control library project. the collection gets displayed properly at design time and i am able to add and remove items also but my problem is that value entered at design time does not effect the control at runtime. Here's the code : First of all I designed a class for creating a List Collection : using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace Funnel { public class SectionValue : CollectionBase { public double this[int index] { get { return ((double)List[index]); } set { List[index] = value; } } public int Add(double value) { return (List.Add(value)); } public int Add(string value) { try { double c = Convert.ToDouble(value); return (List.Add(c)); } catch (Exception) { throw new ArgumentException(string.Format( "Error converting the given string '{0}' to a color", value), "value"); } } public bool Contains(double value) { // If value is not of type Color, this will return false. return (List.Contains(value)); } public int IndexOf(double value) { return (List.IndexOf(value)); } public void Insert(int index, double value) { List.Insert(index, value); } public void Remove(double value) { List.Remove(value); } public SectionValue(double[] sections) : base() { foreach (double s in sections) { this.Add(s); } } public SectionValue() : base() {} } } Then I use object of the class in my control as follows : protected SectionValue m_SectionValue; and write property for it as follows : [Bindable(true) , Category("Appearance") , Browsable(true) , PersistenceMode(PersistenceMode.Attribute) , DesignerSerializationVisibility(DesignerSerializationVisibility.Content) ] public SectionValue UserDefinedSection { get { if (m_SectionValue == null) m_SectionValue = new SectionValue(); return m_SectionValue; } set { m_SectionValue = value; } } Now this code is working perfectly regarding displaying the collection editor and add/deleting values from it. Even I am able to :)add/delete values from code-behind. But the values added during design time do not get reflected at run-time. If I assign values to collection from code-behind file then the values get reflected at run-time but not from design-time. Thanks & Regards, Ujjaval Modi.