Hi All,
I have a user control with one property like so
Add I have a collection like soCode:namespace WindowsApplication1 { public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } private int myVar; public int MyProperty { get { return myVar; } set { myVar = value; } } } }
Then I have another user control where I want a property to add new user control1's like soCode:namespace WindowsApplication1 { public class Class1 : CollectionBase { public void Add(UserControl1 us) { List.Add(us); } public void Remove(UserControl1 us) { List.Remove(us); } public UserControl1 this[int index] { get { return (UserControl1)List[index]; } set { List[index] = value; } } } }
But I can add them in the IDE but when I run the program there are no user control 1's in the list.Code:namespace WindowsApplication1 { public partial class UserControl2 : UserControl { public UserControl2() { InitializeComponent(); } private Class1 myVar; public Class1 MyProperty { get { if (myVar == null) { myVar = new Class1(); } return myVar; } set { myVar = value; } } } }
Why?
Thanks
Loftty




Reply With Quote