Click here to Skip to main content
15,901,122 members
Home / Discussions / C#
   

C#

 
QuestionHow can I synchronize two MS Access tables? Pin
AngryC30-Jun-06 20:08
AngryC30-Jun-06 20:08 
AnswerRe: How can I synchronize two MS Access tables? Pin
DeloreanMag30-Jun-06 20:16
DeloreanMag30-Jun-06 20:16 
Questionset and get for ArrayList Pin
foysal mamun30-Jun-06 18:49
foysal mamun30-Jun-06 18:49 
AnswerRe: set and get for ArrayList Pin
engsrini30-Jun-06 22:29
engsrini30-Jun-06 22:29 
GeneralRe: set and get for ArrayList Pin
foysal mamun1-Jul-06 20:52
foysal mamun1-Jul-06 20:52 
QuestionXML doc & Namespace [modified] Pin
Super Lloyd30-Jun-06 17:22
Super Lloyd30-Jun-06 17:22 
AnswerRe: XML doc & Namespace Pin
LongRange.Shooter3-Jul-06 5:55
LongRange.Shooter3-Jul-06 5:55 
QuestionRecursive treeview with database Pin
ronaldve30-Jun-06 11:11
ronaldve30-Jun-06 11:11 
Hi,
I'm trying to learn C# and am making a little program that retreives product groups from a database.
The productgroups are linked with eachother and can have a unlimited amount of levels.
To give you a id, this is basicly the structure of the table with groups:

id | parent_id
--------------
1  | 
2  |
3  | 1
4  | 1
5  | 4
6  | 6


Wat I want to make is a treeview with the nodes arranged this way:

1
|_3
|_4
| |_5
|   |_6
2

The code i'm having now is this:

public void PopulateTreeView()
{
    DataTable myParentDataTable = getParents();
    for (int i = 0; i < myParentDataTable.Rows.Count; i++)
    {
        TreeNode parentNode = new TreeNode(myParentDataTable.Rows[i]["naam"].ToString());
        parentNode.Name = myParentDataTable.Rows[i]["id"].ToString();
        treeViewLeft.Nodes.Add(parentNode);

        PopulateChilds(parentNode, (int)myParentDataTable.Rows[i]["id"]);
    }
}

private void PopulateChilds(TreeNode tnParentNode, int iParentId)
{
    DataTable myChildDataTable = getChilds(iParentId);
    for (int j = 0; j < myChildDataTable.Rows.Count; j++)
    {
        TreeNode childNode = new TreeNode(myChildDataTable.Rows[j]["naam"].ToString());
        childNode.Name = myChildDataTable.Rows[j]["id"].ToString();
        tnParentNode.Nodes.Add(childNode);

        //PopulateChilds(tnParentNode, (int)myChildDataTable.Rows[j]["id"]);
    }
}


In the last function i've commented-out a line that calls the same function again.
But that's not working the way I want it and i don't know what i should do to get it working right.
Right now it's making the parent nodes and placing all the other nodes inside the parent nodes instead of making parent nodes within the parent nodes and so on.

So, does someone know how to get this wotking?
I probably have to make some changes to the PopulateChilds() function but i've no clue what to do.
I've tried several pieces of code found on this website but i just couldn't get it working the right way.

Thanks!
AnswerRe: Recursive treeview with database Pin
Super Lloyd30-Jun-06 17:35
Super Lloyd30-Jun-06 17:35 
GeneralRe: Recursive treeview with database Pin
ronaldve30-Jun-06 23:13
ronaldve30-Jun-06 23:13 
GeneralRe: Recursive treeview with database Pin
ronaldve1-Jul-06 9:13
ronaldve1-Jul-06 9:13 
Questionplugin based applications in C# projects Pin
sawerr30-Jun-06 9:18
sawerr30-Jun-06 9:18 
AnswerRe: plugin based applications in C# projects Pin
Ravi Bhavnani30-Jun-06 9:36
professionalRavi Bhavnani30-Jun-06 9:36 
GeneralRe: plugin based applications in C# projects Pin
sawerr30-Jun-06 9:43
sawerr30-Jun-06 9:43 
GeneralRe: plugin based applications in C# projects Pin
Ravi Bhavnani30-Jun-06 9:47
professionalRavi Bhavnani30-Jun-06 9:47 
GeneralRe: plugin based applications in C# projects Pin
sawerr30-Jun-06 9:57
sawerr30-Jun-06 9:57 
GeneralRe: plugin based applications in C# projects Pin
Ravi Bhavnani30-Jun-06 10:13
professionalRavi Bhavnani30-Jun-06 10:13 
GeneralRe: plugin based applications in C# projects Pin
sawerr30-Jun-06 10:22
sawerr30-Jun-06 10:22 
GeneralRe: plugin based applications in C# projects Pin
Ravi Bhavnani30-Jun-06 10:25
professionalRavi Bhavnani30-Jun-06 10:25 
QuestionC# Class question Pin
joshp121730-Jun-06 9:17
joshp121730-Jun-06 9:17 
AnswerRe: C# Class question Pin
Ravi Bhavnani30-Jun-06 9:33
professionalRavi Bhavnani30-Jun-06 9:33 
QuestionImage transparency when resizing [modified] Pin
Palooka30-Jun-06 8:46
Palooka30-Jun-06 8:46 
QuestionClose current form and then open new form Pin
Saamir30-Jun-06 8:18
Saamir30-Jun-06 8:18 
AnswerRe: Close current form and then open new form Pin
stancrm30-Jun-06 8:31
stancrm30-Jun-06 8:31 
AnswerRe: Close current form and then open new form Pin
wasife30-Jun-06 20:10
wasife30-Jun-06 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.