I have a C# .NET 2.0 project A (class library) that has a form (TreeForm) that uses Tree objects.
I have a project B that has a class Oak that inherits Tree. The class Oak adds some properties to Tree.
class Oak : ProjectA.Tree
{
public string LeafColor;
}
TreeForm.cs in the class library is a form that has a DataGrid that databinds to a BindingList of Tree objects.
When I try to reference and use the TreeForm in project B with my Oak objects, it's looking for objects of type Tree.
// in project B here.
BindingList<Oak> oaklist = BindingList<Oak>();
private void show_treeform_button_Click(object sender, EventArgs e)
{
ProjectA.TreeForm tree_form = new ProjectA.TreeForm(oaklist); // this line gives error
tree_form.Show();
}
I've tried casting the Oak objects to Tree, but I get the error "Cannot convert type Oak to Tree". If I just use the objects in project B as Tree objects it works fine.
How can I use my Oak objects in the TreeForm from project A?