开发者

Collections for multiple component types

Can anyone answer a quick question for me? I'm working on a control that contains multiple types of subcontrol. This is so that it can repres开发者_Python百科ent a heirachial list.

--Group--
  --Company--
    --Site--
--Group--

Due to the increasing complexity I'm looking at the posssibility of using collections. I found an article on code project which covers this topic: http://www.codeproject.com/KB/cs/collcontrolsrichdes.aspx

There are 2 things that I am unsure of.

1) Is it possible to have components containing collecitons of their own (due to this heirachy) 2) Is there a way of making certain "types" optional. By this I mean, for example, a company sometimes a company may not have a group and may appear at the top of the heirachy.


Looks like you need a tree structure.

Here's a simple version:

class Group
{
  List<Company> companies;
}

class Company
{
  Group parentGroup;//Put at null if there is no parent
  List<Site> sites;
}

class Site
{
  Company parentSite;//Put at null if there is no parent
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜