I have this:
public abstract class DRT_Tvw_Abstract : TreeView
{
TableCountMetrics metrics;
public TableCountMetrics Metrics { get => metrics; set => metrics = value; }
public class TableCountMetrics
{
int schemaNameCount = 0;
int tableNameCount = 0;
public int SchemaNameCount { get => schemaNameCount; set => schemaNameCount = value; }
public int TableNameCount { get => tableNameCount; set => tableNameCount = value; }
}
public DRT_Tvw_Abstract() : base()
{
}
}
public class DRT_Tvw_TableList_Unfiltered : DRT_Tvw_Abstract
{
public DRT_Tvw_TableList_Unfiltered() : base()
{
}
public void _CreateTreeView(DataTable dataTable)
{
tableListTreeViewNode = new {treeview node from my class that derives from TreeNode}
Nodes.Add(tableListTreeViewNode);
}
What I want to do is override
the Add
method so I can increment/decrement custom integer properties that are part of my DRT_Tvw_Abstract
class at the same time I Add
a TreeNode
. I started by trying to derive from the TreeNodeCollection
class, but that seems to be a dead-end because I can't figure out what a valid ctor is for the TreeNodeCollection
class
Nodes
(as in Nodes.Add
) is a property. How do I derive from it so I can override the Add
method? I started by creating an override for this poprperty, but I have no clue as to how you override a method (Add
) from within property override code.
public new virtual TreeNodeCollection Nodes
{
//override the Add method from within here somehow?
get
{
return base.Nodes;
}
set
{
}
}
What is the syntax for overriding the TreeNodeCollection class Add(TreeNode) method?