Recursive User Controls?

  • Thread starter Thread starter Michael Carr
  • Start date Start date
M

Michael Carr

Is it possible for a user control to contain instances of itself? i.e. for a
TreeView-style control.

When I try it, I get a Parser error: "Circular file references are not
allowed."

Thanks!!
Michael Carr
 
A user control, fundamentally, is a class. A class is able to hold a
reference to another instance of the same class, which is exactly how you
would implement a linked list. However, you would not want to put in a
reference to the same instance of that class, for this would be a circular
reference. This is the first thing to check.

To be honest, I don't know specifically about a user control, because this
is not the design that I would use. A user control is the mechanism by which
you implement the aggregator design pattern. It is very useful if you want
to encapsulate a collection of controls as a stand-alone reusable entity. If
you are attempting to make a single control - a tree-view-style control - a
better design choice would be to create a custom server control.
 
Check to make sure you are not creating a circular inheritence hierarchy. For Example: C extends B extends A extends C.
 
Back
Top