I am newbie on c#. I want to make a treeview with having point positions data. It's treeview looks like following..
Form1 (parent) Triangle1 (child1) Triangle2 (child2)
If I cliked Triangle1 then I want to have Triangle1's coord informations. But when I maked triangle class and tried to input treeview node..then that makes error.. how can I solve this problem?
addition.. public partial class Form1 : Form { public class BigCanvas { public string Id; public string Name; }
public class Triangle
{
public string Id;
public string Name;
public Point point1;
public Point point2;
public Point point3;
}
public Form1()
{
InitializeComponent();
this.Name = "Draw Triangle";
this.Text = "Draw sample";
}
private void Form1_Load(object sender, EventArgs e)
{
BigCanvas bc1 = new BigCanvas();
bc1.Id = "0";
bc1.Name = "sample1";
Triangle ta1 = new Triangle();
ta1.Id = "01";
ta1.Name = "triangle1";
ta1.point1 = new Point(30, 50);
ta1.point2 = new Point(40,60);
ta1.point3 = new Point(70,80);
TreeNode root = treeView1.Nodes.Add(bc1); // error
root.Nodes.Add(ta1); // error
root.Nodes.Add(ta2); // error
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode current = e.Node;
// Draw with triangle point
}
But I can't add Triangle class to TreeNode!! ... then what is alternative solve to this problem..?