DS said:
Hey guys, I posted this message a few days ago and got no response.. I'm
hoping that someone has at least played with this or can give me some
advice.
Thanks again,
Dan
Hi Dan!
I want to show you an example. I haven't checked for errors, but can give
you an Idea. Hope it helps.
Best Regard
Hans
//---------------------------------------------
private TreeView trvContact = new TreeView();
private string [] RootArray = new string [2];
private string [] Child1Array = new string [2];
private string [] Child2Array = new string [2];
private void initialize_ArrayList ()
{
this.RootArray[0] = "John Doe\nWidgets Inc";
this.RootArray[1] = "Jane Doe\nSomeCo.";
this.Child1Array[0] = "Home Contact";
this.Child1Array[1] = "Work Contact";
this.Child2Array[0] = "HeadOffice Contact";
this.Child2Array[1] = "International Contact";
}//initialize_ArrayList
private void initialize_TreeView ()
{
//locate TreeView
this.trvContact.Location = new point (0,0); //upper left corner
this.trvContact.Size = new Size (200, 400); //width and hight
this.Controls.Add (this.trvContact);
//Add parent to tree
for (int p = 0; p < this.RootArray.Length; p++)
{
TreeNode ChildNode = new TreeNode(RootArray[p].ToString());
ChildNode.Tag = p //a suitable number
this.trvContant.Nodes.Add (ChildNode);
}//for RootArray
//Add ChildNode 1 to ParentNode 2
for (int p = 0; p < this.Child1Array.Length; p++)
{
TreeNode ChildNode = new TreeNode(this.Child1Array[p].ToString());
ChildNode.Tag = 100 + p //a suitable number
this.trvContant.Nodes[0].Nodes.Add (ChildNode);
}// for Child1Array
//Add ChildNode 2 to ParentNode 2
for (int p = 0; p < this.Child2Array.Length; p++)
{
TreeNode ChildNode = new TreeNode(this.Child2Array[p].ToString());
ChildNode.Tag = 200 + p //or a suitable number
this.trvContant.Nodes[1].Nodes.Add (ChildNode);
}// for Child1Array
}//initialize_TreeView
private void Form1_Load (object sender, System.EventArgs e)
{
this.initialize_ArrayList ();
this.initialize_TreeView ();
}
//------------------------------------------------------