大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> NET专区 -> 不用第归算法快速显示树,对于Oracle数据库(2)

不用第归算法快速显示树,对于Oracle数据库(2)

时间: 2021-07-31 作者:daque

namespace bq_treeview{/// <summary> /// bq_treeview 的纲要证明 /// </summary> public class bq_treeview : system.windows.forms.treeview { private system.componentmodel.container components = null; private datatable m_tb=null; private string m_rootmatid; bq_treenode rootnode=null; arraylist alnode=new arraylist (); public bq_treeview() { initializecomponent(); } protected override void dispose( bool disposing ) { if( disposing ) { if(components != null) { components.dispose(); } } base.dispose( disposing ); } #region private void initializecomponent() { components = new system.componentmodel.container(); } #endregion /// <summary> ///设置数据源 /// </summary> public datatable treedatasource { set { m_tb=value; } } /// <summary> ///清空一切树控件中的消息 /// </summary> private void clear() { if(rootnode!=null) { rootnode.nodes .clear (); if(rootnode!=null) { try { rootnode.remove (); } catch {} } } if(alnode!=null) if(alnode.count >0) alnode.clear (); } /// <summary> /// 结构树控件 /// </summary> public void maketree() { clear();//废除树节点中的资源 cursor.current =cursors.waitcursor ; // 开始要给根节点付值,由于掏出来的构造中没有根节点的消息 rootnode=new bq_treenode(m_rootmatid); rootnode.matid =m_rootmatid; alnode.add(rootnode); this.nodes .add (rootnode); foreach(datarow row in m_tb.rows ) { bq_treenode fnode=null; bq_treenode cnode=null; cnode=makearray(row["id"].tostring (),row["物料源代码"].tostring (),out fnode); fnode.nodes.add (cnode); } rootnode.expand (); cursor.current =cursors.default ; }// <summary> /// 结构一个动静数组,模仿树控件一个分叉的线性构造,每一次都是最新的线性构造,这所有控件要害场合 /// </summary> /// <param name="strid">档次</param> /// <param name="matid">物料源代码</param> /// <param name="nodef">父节点</param> /// <returns>结构的节点</returns>。 private bq_treenode makearray(string strid,string matid,out bq_treenode nodef) { try { bq_treenode node=new bq_treenode (matid); node.matid =matid; bq_treenode noderet=null; int ngrade=int.parse (strid); if(ngrade==0) { } else { if(alnode.count>=ngrade+1) { alnode[ngrade]=node; noderet=(bq_treenode)alnode[ngrade-1]; } else { alnode.add (node); noderet=(bq_treenode)alnode[ngrade-1]; } } nodef=noderet; return node; } catch(exception e) { throw new exception("",e); } } public string rootmatid { get { return m_rootmatid; } set { m_rootmatid=value; } } }}过程编写翻译就不妨把控件bq_treeview增添进入,如次图(图2)在运用步调中只有编写bq_treeview1.rootmatid=strrootid; bq_treeview1.treedatasource=tbproinfo; bq_treeview1.maketree();就不妨表露所有bom构造,tbproinfo为上头的sql语句掏出的表构造

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.