调用时如下:
/// <param name="newTreeView">树型控件名称</param>
/// <param name="TreeViewName">一层的功能名称</param>
/// <param name="TableName">数据库中的表名</param>
/// <param name="ParentNameField">父节点的字段名</param>
/// <param name="CurrentNameField">节点的字段名</param>
/// <param name="CurrentDataField">节点的数据</param>
newTreeInfoBll.InitTreeData(this.treeView1,"系统业务表","T_S_SystemTableIndex","pid000","name00","id0000");
有什么不懂的或不明白的地方请大家给我发EMAIL,谢谢,希望大家一起进步
---------------------------------
TREEINFO.CS = 数据控制层
using System;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
/// <summary>
/// TreeInfo
/// 树型初使化数据库的所有信息
/// 乔高峰 2005-04-26
/// 功能:实现所有树型的初使化
/// </summary>
public class TreeInfo
{
// private string PARM_TableName;
/// <summary>
/// 取某表的所有数据(缺少表名)
/// </summary>
private string SQL_SELECT_TREE = "SELECT * FROM ";
/// <summary>
/// 保存结果的数据集
/// scf
/// </summary>
private DataSet newDataSet;
/// <summary>
/// 为过滤方便的视图
/// </summary>
private DataView newDataView;
/// <summary>
/// 无参数的构造函数
/// </summary>
public TreeInfo()
{
}
/// <summary>
/// 初使化树型
/// 乔高峰 2005-04-28
/// </summary>
/// <param name="newTreeView">树型控件名称</param>
/// <param name="TreeViewName">一层的功能名称</param>
/// <param name="TableName">数据库中的表名</param>
/// <param name="ParentNameField">父节点的字段名</param>
/// <param name="CurrentNameField">节点的字段名</param>
/// <param name="CurrentDataField">节点的数据</param>
public void InitTreeData(TreeView newTreeView,string TreeViewName,string TableName,string ParentNameField,string CurrentNameField,string CurrentDataField)
{
//增加第一层节点的名称,为该树的功能名称
TreeNode newTreeViewName = new TreeNode();
//设置该节点的显示文本
newTreeViewName.Text = TreeViewName;
////树型的图标
//newTreeViewName.ImageIndex = ;
////选择时的图标
//newTreeViewName.SelectedImageIndex = ;
newTreeView.Nodes.Add(newTreeViewName);
//增加第二层数据库里最高层的数据
//从数据库中取数据
try
{