Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I did a Pre-Order and an In-Order as on the picture, but I don't know how to do the Post-Order in a TreeView.

I know my code looks stupid. I tried that if a number is different from the first row value of the row then it changes the color of the row, so I wanted to implement this into my treeview, so there is the root number as the first value, then if next value is bigger then in the TreeView the number goes above of the root number othervise below.

Is there any other way to do it a post-order sort in treeview by it content?

Sorry for my english, also I am beginner in C#.

What I have tried:

int a = Convert.ToInt32(dataGridView1.Rows[0].Cells[3].Value);
                int b = Convert.ToInt32(row.Cells[3].Value);
                for (int i = 1; i < dataGridView1.Rows.Count; i++)
                    if (a <= b)
                        row.DefaultCellStyle.BackColor = Color.FromArgb(144, 238, 144);
                        panel1.BackColor = Color.FromArgb(144, 238, 144);
                        //int rowIndex = i;
                        //treeViewPost.Nodes.Add("B " + dataGridView1.Rows[i].Cells[3].Value.ToString());
                        //int rowIndex = i ;
                        row.DefaultCellStyle.BackColor = Color.FromArgb(255, 106, 106);
                        panel4.BackColor = Color.FromArgb(255, 106, 106);
                        treeViewPost.Nodes.Add("S " + dataGridView1.Rows[i].Cells[3].Value.ToString());

Dirk Bahle 16-Sep-18 3:21am    
Not sure about your code - its hard to tell what it is supposed todo but I wrote an article on tree view traversal in WPF and it might help you with WinForms as well since both are build on C#/.Net. If anything, you could use the article to verify if your algorithmic coding looks similar to what I posted or not. Just look through my articles and find the TreeView article on level order traversals ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900