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. Object instance from propertyDescriptor type

Object instance from propertyDescriptor type

Scheduled Pinned Locked Moved C#
cssquestion
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.
  • T Offline
    T Offline
    the last free name
    wrote on last edited by
    #1

    I've (nearly) written a custom collection implementing IBindingList and ITypedList to use a datasource for the Datagrid. The collection takes in the constructor the type of object the list will hold. myCollection vehicleList = new MyCollection(typeof(Vehicle)); Using ITypedListGetItemProperties I then get a PropertyDescriptorCollection of Vehicle as the grid column header source. This all works fine. However I intended that Vehicle could have a collection. Public Class Vehicle { Class Vehicle(){} // lots of properties private MyCollection peopleList = new myCollection(typeof(People)) public myCollection PeopleList { get{return peopleList;} } } when selecting this sublist as a link within the datagrid I'd like to re-use ITypedList.GetItemProperties to retrieve the public properties of type People. So far I can identify the PropertyDescriptor for peopleList and it's type of MyCollection, but I can't get the instace of peopleList needed to retrieve it's collection type of People. From which I can then build the PropertyDescriptorCollection for People. Is is possible to get the instance to which the propertyDescriptor is refering? If not I've wasted a lot of time getting this far X|

    H 1 Reply Last reply
    0
    • T the last free name

      I've (nearly) written a custom collection implementing IBindingList and ITypedList to use a datasource for the Datagrid. The collection takes in the constructor the type of object the list will hold. myCollection vehicleList = new MyCollection(typeof(Vehicle)); Using ITypedListGetItemProperties I then get a PropertyDescriptorCollection of Vehicle as the grid column header source. This all works fine. However I intended that Vehicle could have a collection. Public Class Vehicle { Class Vehicle(){} // lots of properties private MyCollection peopleList = new myCollection(typeof(People)) public myCollection PeopleList { get{return peopleList;} } } when selecting this sublist as a link within the datagrid I'd like to re-use ITypedList.GetItemProperties to retrieve the public properties of type People. So far I can identify the PropertyDescriptor for peopleList and it's type of MyCollection, but I can't get the instace of peopleList needed to retrieve it's collection type of People. From which I can then build the PropertyDescriptorCollection for People. Is is possible to get the instance to which the propertyDescriptor is refering? If not I've wasted a lot of time getting this far X|

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      the last free name wrote: So far I can identify the PropertyDescriptor for peopleList and it's type of MyCollection... What exactly do you mean by "I can". Do you mean the code you've written can, you can through the debugger or through Type discovery? Please be specific. Also, you really only need to implement ITypedList if you need to customize the properties exposed to bindable controls. Controls that implement binding correctly (like those defined in the .NET Framework Class Library) use the BindingManagerBase class for binding, from which CurrencyManager and PropertyManager derive. If you bind your collection of objects correctly (see the DataGridTableStyle.MappingName property for more information and an example) then you get binding for free. Implementing IBindingList, on the other hand, is a custom feat that really depends on your requirements, but the basic implementation you also get for free. For example, if your collection (or, rather, list) returns true for IList.IsReadOnly then items can't be added and the UI appears appropriately. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

      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