DataSet dtTree = ObjUser.GetAllClientGroupandList();
TreeView1.Nodes.Clear();
if (dtTree != null)
{
// Create DataRelation.................
DataRelation rel = new DataRelation("ClientCategory", dtTree.Tables[0].Columns["TPAClientGroupId"],
dtTree.Tables[1].Columns["TPAClientGroupId"], false);
rel.Nested = true;
dtTree.Relations.Add(rel);
// Set the Attribute here .........................
foreach (DataColumn dc in dtTree.Tables[0].Columns)
{
dc.ColumnMapping = MappingType.Attribute;
}
foreach (DataColumn dc in dtTree.Tables[1].Columns)
{
dc.ColumnMapping = MappingType.Attribute;
}
// xml decleartion ......................................
XmlDataSource xmlD = new System.Web.UI.WebControls.XmlDataSource();
xmlD.ID = "XmlDataSource1";
// Call GetXml and assign to xml data source.
XmlDataSource1.Data = dtTree.GetXml();
}
你不能做什麼?您是否嘗試過創建新的TreeNode並將其添加到Root/TreeView控件的其他節點的ChildNodes? – sll
你的問題沒有正確的方式問,沒有人容易理解你的問題。讓任何人都能簡單易懂。 –
http://stackoverflow.com/questions/9802724/how-to-create-a-multicolumn-treeview-like-this-in-c-sharp-winforms-app/9802753#9802753檢查此鏈接..問題解決。 :) –