2015-01-09 1 views
0

WCF가 데이터베이스와 연결되어 있고 Employee 테이블을 사용하여 NOrthWind 데이터베이스에서 데이터를 검색 할 때이 Intormation을 treeview 컨트롤을 사용하여 Windows 양식에 표시하려고합니다. Employee 테이블의 Northwind 데이터베이스에있는 정보는 트 리뷰 컨트롤에 표시되어야합니다.TreeView를 사용하여 wcf 연결에서 데이터 표시

답변

0

개인 무효를 Button1_Click (개체 송신자있는 EventArgs E) {

 EmpTree.Employee display = new EmpTree.Employee(); 

     TreeNode head = new TreeNode(); 

     TreeNode tnParent = new TreeNode(); 
     treeView1.Nodes.Clear(); 

     head = new TreeNode("Employee Details"); 

     treeView1.Nodes.Add(head); 
     treeView1.Nodes.Add(tnParent); 

     Fillchild(tnParent); 

    } 

    //=========================================Fill Child With Data======================================== 
    public void Fillchild(TreeNode parent) 
    { 

     EmpTree.Service1Client myDisplay = new EmpTree.Service1Client(); 

     foreach (var employee in myDisplay.getEmployees()) 
     { 
      TreeNode child = new TreeNode(); 
      child.Nodes.Add("Employee ID" + " " + employee.Employee_ID.ToString()); 
      child.Nodes.Add("Employee First Name" + " " + employee.FirstName); 
      child.Nodes.Add("Employee Last Name:" + " " + employee.LastName); 
      child.Nodes.Add("Employee Title:" + " " + employee.Title); 
      child.Nodes.Add("birth Date:" + " " + employee.BirthDate.ToLongDateString()); 
      child.Nodes.Add("Home Phone No:" + " " + employee.HomePhone); 
      child.Nodes.Add("Report To:" + " " + employee.ReportsTo.ToString()); 
      parent.Nodes.Add(child); 
     } 
    }