473,320 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Inheriting BindingList(Of T)

1
Please see the below example:

Expand|Select|Wrap|Line Numbers
  1. Imports System.ComponentModel
  2.  
  3. Public Class level1Collection(Of T As level1Item)
  4.     Inherits BindingList(Of T)
  5.  
  6.     Public Sub Load()
  7.         Dim i As T = Me.AddNew
  8.     End Sub
  9. End Class
  10.  
  11. Public Class level2Collection(Of T As level2Item)
  12.     Inherits level1Collection(Of level2Item)
  13. End Class
  14.  
  15. Public Class level3Collection(Of T As level3Item)
  16.     Inherits level2Collection(Of level3Item)
  17. End Class
  18.  
  19. Public Class level4Collection(Of T As level4Item)
  20.     Inherits level3Collection(Of level4Item)
  21. End Class
  22.  
  23. Public Class level1Item
  24.  
  25. End Class
  26.  
  27. Public Class level2Item
  28.     Inherits level1Item
  29. End Class
  30.  
  31. Public Class level3Item
  32.     Inherits level2Item
  33. End Class
  34.  
  35. Public Class level4Item
  36.     Inherits level3Item
  37. End Class
  38.  
  39.  
  40. Public Class Worker
  41.     Sub New()
  42.         Dim c As New level4Collection(Of level4Item)
  43.         c.Load()
  44.     End Sub
  45. 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 level1collection, 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 level1collection is as follows

Expand|Select|Wrap|Line Numbers
  1. {Name = "level4Collection`1" FullName = "DemoApp.level4Collection`1[[DemoApp.level4Item, DemoApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
  2.     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.
Oct 4 '11 #1
0 1250

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: richardlane | last post by:
Hi, basic question here - I'm struggling with the transfer from asp to asp.net a bit, especially in seeing the 'bigger picture' of how things are best structured. I have a website made up...
15
by: JustSomeGuy | last post by:
this doesn't want to compile.... class image : public std::list<element> { element getElement(key k) const { image::iterator iter; for (iter=begin(); iter != end(); ++iter) { element...
29
by: shaun roe | last post by:
I want something which is very like a bitset<64> but with a couple of extra functions: set/get the two 32 bit words, and conversion to unsigned long long. I can do this easily by inheriting from...
1
by: john diss | last post by:
hello there everyone.. I have created a class called "ProcessLog" inheriting from XmlDocument and two classes ("UploadedItem", "ProcessError") inheriting from XmlElement. I then have two...
2
by: Peter Bates | last post by:
Hi, I'm just getting used to XSDObjectGen and i have the following question. Can i use a class inherited from a class generated by XSDObjectGen with XmlSerialize? Specifically, I have many...
11
by: Noah Coad [MVP .NET/C#] | last post by:
How do you make a member of a class mandatory to override with a _new_ definition? For example, when inheriting from System.Collections.CollectionBase, you are required to implement certain...
0
by: z. f. | last post by:
Hi, I'm not so familiar with control inheriting, but what i need is very simple (should be) and requires only deep knowledge with implementing control inheritence. is it possible (might someone...
2
by: Shayne H | last post by:
I wanted to create a type-safe collection by inheriting from CollectionBase. Public Class MyCollection : Inherits CollectionBase I found that IList.Add did not allow the setting of a "key" to...
2
by: Charles Law | last post by:
I want a set of controls that all have a border, like a group box. I thought I would create a base control containing just a group box from which my set of controls could inherit. Assuming that...
3
by: Alex Satrapa | last post by:
There's some mention in the (old!) documentation that constraints such as foreign keys won't include data from inheriting tables, eg: CREATE TABLE foo ( id SERIAL PRIMARY KEY ); CREATE TABLE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.