So here is code i have in my Form class:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
BstTree tree = new BstTree();
tree.addRoot(50);
for (int i = 1; i < 50; i++)
{
int b = rnd.Next(1, 100);
listBox1.Items.Add(b);
tree.AddNode(tree.root, b);
}
tree.treeOutput(tree.root, this);
}
public void draw(Point prevPT, Point currentPT)
{
Graphics p = CreateGraphics();
Pen pen = new Pen(Color.Red, 5);
p.DrawLine(pen, prevPT, currentPT);
}
}
And i have BstTree class and i call the draw method from there:
public Class BstTree
{
public void treeOutput(Node root, Form1 f)
{
Label node = new Label();
node.AutoSize = true;
node.Text = root.value.ToString();
node.Location = pt;
root.ancPT = pt;
f.Controls.Add(node);
f.draw(root.ancestor.ancPT, pt);
}
}
but it doesnt draw anything, have no idea how to solve this...