偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

C#treeview遞歸操作數(shù)據(jù)庫淺析

開發(fā) 后端
C# treeview遞歸操作數(shù)據(jù)庫主要是想大家展示通過C# treeview遞歸來實(shí)現(xiàn)數(shù)據(jù)庫的樹形結(jié)構(gòu)的呈現(xiàn),希望對你了解C# treeview遞歸有所比幫助。

C# treeview遞歸操作數(shù)據(jù)庫需要注意什么呢?C# treeview遞歸操作數(shù)據(jù)庫的具體步驟是什么呢?這里我們通過具體的實(shí)現(xiàn)步驟來向你詳細(xì)介紹相應(yīng)的內(nèi)容。

C# treeview遞歸1、建立數(shù)據(jù)庫:

f_id 項(xiàng)目ID號 ,f_front 父ID號 ,f_name名稱,f_type類型,f_layer所處層,f_order 同層的順序號;(f_layer,f_order不要也可,這里我主要是需要同層排序才用到)

C# treeview遞歸2、數(shù)據(jù)庫的操作

然后“select f_id,f_front,f_name,f_type from data”取得DataSet數(shù)據(jù)集dsFrame;treeview 名稱設(shè)為tvDept

C# treeview遞歸3、寫函數(shù) 構(gòu)建treeveiw樹形:

  1. public void AddTree(int ParentID, TreeNode pNode)  
  2.  
  3. { DataView dvTree = new DataView(dtTree);   
  4. //就是dtTree = dsFrame.Tables[0];   
  5. string Fstr = "[f_front] = " + ParentID; dvTree.RowFilter = Fstr;  
  6.  
  7. foreach(DataRowView Row in dvTree)  
  8.  
  9. { TreeNode Node = new TreeNode();   
  10. if (pNode == null//處理主節(jié)點(diǎn)  
  11.  
  12. { Node.Name = Row["f_id"].ToString();   
  13. //這里+了2個(gè)值分別到Name和Text,可隨便  
  14.  
  15. Node.Text = Row["f_name"].ToString();  
  16.  
  17. if (Row["f_type"].ToString() == "崗位")   
  18. //這個(gè)不要也可以,主要為了不同類型顯示不同圖標(biāo) { Node.ImageIndex = 1; Node.SelectedImageIndex=1; }  
  19.  
  20. else 
  21.  
  22. { Node.ImageIndex = 0; Node.SelectedImageIndex=0; }  
  23.  
  24. tvDept.Nodes.Add(Node);   
  25. //加入 AddTree(Int32.Parse(Row["f_id"].ToString()), Node); //遞歸  
  26.  
  27. else //處理子節(jié)點(diǎn)  
  28.  
  29. { Node.Name = Row["f_id"].ToString(); Node.Text = Row["f_name"].ToString();  
  30.  
  31. if (Row["f_type"].ToString() == "崗位")  
  32.  
  33. { Node.ImageIndex = 1; Node.SelectedImageIndex = 1; }  
  34.  
  35. else { Node.ImageIndex = 0; Node.SelectedImageIndex=0; }  
  36.  
  37. pNode.Nodes.Add(Node);  
  38.  
  39. AddTree(Int32.Parse(Row["f_id"].ToString()), Node); }  
  40.  
  41. }  
  42.  
  43. }  

C# treeview遞歸4、調(diào)用實(shí)現(xiàn)

調(diào)用方法 AddTree(0, (TreeNode)null); //0就是處于最高級其f_front=0,數(shù)據(jù)庫里1為頂層那就是1,這個(gè)隨便 最好+一句 tvDept.ExpandAll(); 展開所有項(xiàng)。

C# treeview遞歸的數(shù)據(jù)庫操作我們就向你介紹到這里,希望對你了解和學(xué)習(xí)C# treeview遞歸有所幫助。

【編輯推薦】

  1. C#程序設(shè)計(jì)獲取系統(tǒng)信息的Windows窗體淺析
  2. C#遞歸算法理解的實(shí)例分析
  3. C#遞歸思路的使用實(shí)例詳解
  4. C#遞歸函數(shù)應(yīng)用實(shí)例解析
  5. DropDownList顯示的C#遞歸實(shí)現(xiàn)淺析
責(zé)任編輯:仲衡 來源: 百度空間
相關(guān)推薦

2011-07-01 13:42:24

QT 數(shù)據(jù)庫

2009-09-15 09:50:07

Linq操作數(shù)據(jù)庫

2009-08-24 16:46:04

C# 泛型

2020-11-16 08:56:02

Python

2011-07-05 10:27:06

MySQL數(shù)據(jù)庫檢索排序

2011-04-19 10:20:09

數(shù)據(jù)庫

2023-12-27 13:44:00

數(shù)據(jù)庫系統(tǒng)分布式

2023-04-27 09:36:43

2023-12-14 15:07:31

多線程數(shù)據(jù)庫代碼

2009-08-19 16:30:55

C#操作Access數(shù)

2009-07-07 09:24:37

LINQ檢索

2009-08-19 16:40:26

C#操作Access數(shù)

2016-05-11 10:09:49

數(shù)據(jù)層代碼FastQuery

2023-06-15 15:21:43

2009-08-04 14:52:33

Visual Web ASP.NET

2009-12-28 16:57:40

ADO .NET 類

2023-05-23 16:25:48

MyBatisSQL數(shù)據(jù)庫

2022-10-09 15:41:54

Python數(shù)據(jù)庫

2021-01-29 10:51:48

高并發(fā)數(shù)據(jù)庫緩存

2021-06-29 06:25:22

Nest.jsTypeORM數(shù)據(jù)庫
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號