DevExpress TreeList Control

為{幸葍}努か 提交于 2019-12-14 04:26:14

问题


I need to display the xml data in the treelist control. I have one root node, one Child node and further four children for this child node.

I am not able to display it in the treelist. I am using the dataset.readXml method for reading the xml file and giving dataset as a datasource. Here is the code I am following:

DataSet dataSet = new DataSet();
dataSet.ReadXml(@"C:\foldersettings.xml");
treeList2.DataSource = dataSet;
treeList2.PopulateColumns();
treeList2.BestFitColumns();
treeList2.ExpandAll();

Can anyone tell me why am I not getting the data in treelist. I am using DevExpress 9.1 version control.


回答1:


DataSet dataSet = new DataSet();
dataSet.ReadXml(@"C:\foldersettings.xml");
treeList2.DataSource = dataSet.Table[0];
treeList2.PopulateColumns();
treeList2.BestFitColumns();
treeList2.ExpandAll(); 



回答2:


You should also set the KeyFieldName and ParentFieldName properties of the TreeList. Note, these properties should be set to the corresponding field names in the CaseSensitive manner. Also, the TreeList's DataSource should be set to dataSet.Tables[0]. I hope, this will help.




回答3:


This treeList , from DevExpress will work fine if it will found in your DataSet dataSet in the first column Unique ID's, because it takes as Primary Keys, also, it must find a second column which will be considered like ParentId's.



来源:https://stackoverflow.com/questions/3658919/devexpress-treelist-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!