Inheriting BindingList(Of T)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • taxair
    New Member
    • Oct 2011
    • 1

    Inheriting BindingList(Of T)

    Please see the below example:

    Code:
    Imports System.ComponentModel
    
    Public Class level1Collection(Of T As level1Item)
        Inherits BindingList(Of T)
    
        Public Sub Load()
            Dim i As T = Me.AddNew
        End Sub
    End Class
    
    Public Class level2Collection(Of T As level2Item)
        Inherits level1Collection(Of level2Item)
    End Class
    
    Public Class level3Collection(Of T As level3Item)
        Inherits level2Collection(Of level3Item)
    End Class
    
    Public Class level4Collection(Of T As level4Item)
        Inherits level3Collection(Of level4Item)
    End Class
    
    Public Class level1Item
    
    End Class
    
    Public Class level2Item
        Inherits level1Item
    End Class
    
    Public Class level3Item
        Inherits level2Item
    End Class
    
    Public Class level4Item
        Inherits level3Item
    End Class
    
    
    Public Class Worker
        Sub New()
            Dim c As New level4Collection(Of level4Item)
            c.Load()
        End Sub
    End Class
    '************** *************** ***************
    'Basically I have 4 levels of inheritance, representing the core object all the way through the application level object. When I create "c" in the worker object. It creates a bindinglist(of level4items). When I call c.Load. which is inherited from the level1collectio n, the item that is created in the Me.AddNew is a level2item, not a level4item. Why is the base list creating in object from level 2 rather than level 4? The "type" of "Me" when I look in the level1collectio n is as follows

    Code:
    {Name = "level4Collection`1" FullName = "DemoApp.level4Collection`1[[DemoApp.level4Item, DemoApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
        System.RuntimeType: {Name = "level4Collection`1" FullName = "DemoApp.level4Collection`1[[DemoApp.level4Item, DemoApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
    Yet it still creates a level2item.

    Thank you in advance, this is a simplified question to a rather large problem i'm facing.

    Thanks.
    Last edited by Niheel; Oct 5 '11, 02:18 AM. Reason: additional info
Working...