Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. using list object as a public property in custom control

using list object as a public property in custom control

Scheduled Pinned Locked Moved C#
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shoaib Hussain
    wrote on last edited by
    #1

    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.

    M 1 Reply Last reply
    0
    • S Shoaib Hussain

      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.

      M Offline
      M Offline
      mikker_123
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups