Hi...
I am working with treeview, now I want to add combox1 items from treeview on form load..
how it is possible..?
any body help me
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Soft CornerPosted May 6, 2011, 3:15 AM
void DisplayChildNodeText(TreeNode node)
{
//add nodes to comboBox
comboBox1.Items.Add(node.Text);
}
it will take only parent nodes to comboBox.
Kanhialal kkPosted May 6, 2011, 7:41 AM
I have not created database yet, because I am confuse that how to store parent and child node into database...
please suggest me...
Soft CornerPosted May 6, 2011, 7:24 AM
Can you plz tell me , howz your database table looks like?
in which manner you want to store Parent & child node to DB?
Kanhialal kkPosted May 6, 2011, 6:44 AM
Now I want to save the Tree view record as Parent Node as well as Child nodes in database...
also retrieve from database and put it into tree view..
suppose I have 4 parent nodes and also each Parent node has 4 child..
So kindly help me..
Soft CornerPosted May 6, 2011, 3:05 AM
Try this code .. it will add all nodes of treeview to comboBox as a item.
public Form()
{
InitializeComponent();
if (LinksTreeView.Nodes.Count > 0)
{
// Iterate through the root nodes in the Nodes property.
for (int i = 0; i < LinksTreeView.Nodes.Count; i++)
{
// Display the nodes.
DisplayChildNodeText(LinksTreeView.Nodes[i]);
}
}
else
{
MessageBox.Show("The TreeView control does not have any nodes.");
}
}
void DisplayChildNodeText(TreeNode node)
{
//add nodes to comboBox
comboBox1.Items.Add(node.Text);
for (int i = 0; i < node.Nodes.Count; i++)
{
// Recursively call the DisplayChildNodeText method to
// traverse the tree and display all the child nodes.
DisplayChildNodeText(node.Nodes[i]);
}
}