Question : DevExpress XtraTreeList - tree structure

I am able to populate an XtraTreeList control from a DataTable, but no tree nodes are created. Why do the records appear beneath each other, not in a tree structure?

I'm using the following code:
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
DataTable dtAssignedCodes = getDatatable();
 
tvwInvcodes.ParentFieldName = "TreeID";
tvwInvcodes.KeyFieldName = "RowNumber";
tvwInvcodes.DataSource = dtAssignedCodes;
tvwInvcodes.OptionsBehavior.PopulateServiceColumns = true;
tvwInvcodes.PopulateColumns();
tvwInvcodes.BestFitColumns();
tvwInvcodes.ExpandAll();

Answer : DevExpress XtraTreeList - tree structure

make sure that all data has proper parent key...  
like...

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
			DataTable dt = new DataTable();
			dt.Columns.Add("TreeID",typeof(Int32));
			dt.Columns.Add("RowNumber" , typeof(Int32));
			dt.Columns.Add("nam" , typeof(string));
 
			dt.Rows.Add(new object[] {0,1,"Aaaa"});
			dt.Rows.Add(new object[] {1,2,"Bbbb"});
			dt.Rows.Add(new object[] { 1 , 3 , "Cccc" });
 
			tvwInvcodes.ParentFieldName = "TreeID";
			tvwInvcodes.KeyFieldName = "RowNumber";
			tvwInvcodes.DataSource = dt;
			tvwInvcodes.OptionsBehavior.PopulateServiceColumns = true;
			tvwInvcodes.PopulateColumns();
			tvwInvcodes.BestFitColumns();
			tvwInvcodes.ExpandAll();
Random Solutions  
 
programming4us programming4us