using list object as a public property in custom control
-
I have created a Serializable class named "Student". [Serializable] public class Student { } Also created a custom user control. then i used the list in the custom user control. public class myControl : UserControl { List students; public List Students { set { students = value; } get { return students; } } } the controls is performing exact and there is no any compilation error. but if i use this control on any form then designer view of that form vanished out and display this error. Object of type 'System.Collections.Generic.List`1[WindowsControlLibrary1.Student]' cannot be converted to type 'System.Collections.Generic.List`1[WindowsControlLibrary1.Student]'. Kindly help that why the designer view of this form vanished out.
-
I have created a Serializable class named "Student". [Serializable] public class Student { } Also created a custom user control. then i used the list in the custom user control. public class myControl : UserControl { List students; public List Students { set { students = value; } get { return students; } } } the controls is performing exact and there is no any compilation error. but if i use this control on any form then designer view of that form vanished out and display this error. Object of type 'System.Collections.Generic.List`1[WindowsControlLibrary1.Student]' cannot be converted to type 'System.Collections.Generic.List`1[WindowsControlLibrary1.Student]'. Kindly help that why the designer view of this form vanished out.
Code you gave doesn't tell much, for example I don't see any relation with UserControl and Student class. It could be possible that you initialize student class in Control constructor (use Load event instead and use if (!DesignMode) { }), or that you have two Student classes... So please provide more code (like complete definition of both classes). P.