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. IBindingList implementation

IBindingList implementation

Scheduled Pinned Locked Moved C#
helpai-modelsbusinesstutorialquestion
3 Posts 3 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.
  • B Offline
    B Offline
    bertvan
    wrote on last edited by
    #1

    Hello, I have a generic class BindingCollection<T> : IBindingList The purpose of this class is to collect Business Objects and functionality around them (LoadAll, New ...). I implemented IBindingList so I could be able to bind it to a DataGridView (with BindingSource) and when changes occur to the BindingCollection, the DataGridView would notice and update itself and vice versa. I think that so far, this is a logical setup, no? Now I'm wondering how I should implement the IBindingList interface methods. Should I make a class-variable BindingList<T> list and when, for example, AddIndex(...) is called, do something like public void AddIndex(PropertyDescriptor property) {   ((IBindingList)list).AddIndex(property); } At the moment I implemented all interface methods in a similar way, but even though my inner list gets updated nicely, the DataGridView still doesn't notice any changes nor does it update it's presented data. Any help would be very welcome, because I have been struggling with this problem for quite a while, and you could help me a lot further. Greets, Bert

    R E 2 Replies Last reply
    0
    • B bertvan

      Hello, I have a generic class BindingCollection<T> : IBindingList The purpose of this class is to collect Business Objects and functionality around them (LoadAll, New ...). I implemented IBindingList so I could be able to bind it to a DataGridView (with BindingSource) and when changes occur to the BindingCollection, the DataGridView would notice and update itself and vice versa. I think that so far, this is a logical setup, no? Now I'm wondering how I should implement the IBindingList interface methods. Should I make a class-variable BindingList<T> list and when, for example, AddIndex(...) is called, do something like public void AddIndex(PropertyDescriptor property) {   ((IBindingList)list).AddIndex(property); } At the moment I implemented all interface methods in a similar way, but even though my inner list gets updated nicely, the DataGridView still doesn't notice any changes nor does it update it's presented data. Any help would be very welcome, because I have been struggling with this problem for quite a while, and you could help me a lot further. Greets, Bert

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      Hi, have you bound the ListChanged event of the inner class? If not then do so and rethrow the event within your class. Robert

      1 Reply Last reply
      0
      • B bertvan

        Hello, I have a generic class BindingCollection<T> : IBindingList The purpose of this class is to collect Business Objects and functionality around them (LoadAll, New ...). I implemented IBindingList so I could be able to bind it to a DataGridView (with BindingSource) and when changes occur to the BindingCollection, the DataGridView would notice and update itself and vice versa. I think that so far, this is a logical setup, no? Now I'm wondering how I should implement the IBindingList interface methods. Should I make a class-variable BindingList<T> list and when, for example, AddIndex(...) is called, do something like public void AddIndex(PropertyDescriptor property) {   ((IBindingList)list).AddIndex(property); } At the moment I implemented all interface methods in a similar way, but even though my inner list gets updated nicely, the DataGridView still doesn't notice any changes nor does it update it's presented data. Any help would be very welcome, because I have been struggling with this problem for quite a while, and you could help me a lot further. Greets, Bert

        E Offline
        E Offline
        Ed Poore
        wrote on last edited by
        #3

        Indexes you have to manage yourself (I looked into implementing the same thing), if you look at the source code in Reflector (if you can get your head around the way things have been implemented), then you'll see that (I think it was anyway) AddIndex will throw a NotImplemented exception. You basically have to manage your own indexes, I seem to remember there was one method which you could override which would be fired when anything changed. Can't remember the name of it but if you want it I can dig it up tomorrow sometime when I put the other disk back in (and when I have time). Possibly the simplest way to maintain indexes is to have a dictionary object to provide looking up the indexes. Maybe, I'm not sure though. There doesn't seem to be very much documentation on the subject at all. Don't hesitate to ask if you want further help as I did spend quite a bit of time figuring out what was going on (just got to remember what it was :rolleyes:).


        Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed

        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