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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Soft CornerRank #1,221 · 1.5K reputationPosted May 5, 2011, 11:15 PM EDT
void DisplayChildNodeText(TreeNode node)
{
//add nodes to comboBox
comboBox1.Items.Add(node.Text);
}
it will take only parent nodes to comboBox.
Soft CornerRank #1,221 · 1.5K reputationPosted May 5, 2011, 11:05 PM EDT
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]);
}
}
Kanhialal kkRank #8,477 · 221 reputationPosted May 6, 2011, 2:44 AM EDT
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 CornerRank #1,221 · 1.5K reputationPosted May 6, 2011, 3:24 AM EDT
Can you plz tell me , howz your database table looks like?
in which manner you want to store Parent & child node to DB?
Kanhialal kkRank #8,477 · 221 reputationPosted May 6, 2011, 3:41 AM EDT
I have not created database yet, because I am confuse that how to store parent and child node into database...
please suggest me...