国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > 綜合 > 正文

不用第歸算法快速顯示樹(shù),對(duì)于Oracle數(shù)據(jù)庫(kù)(2)

2024-07-21 02:23:50
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

namespace bq_treeview

{/// <summary>

/// bq_treeview 的摘要說(shuō)明

/// </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>

///定義數(shù)據(jù)源

/// </summary>

public datatable treedatasource

{

set

{

m_tb=value;

}

}

/// <summary>

///清空所有樹(shù)控件中的信息

/// </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>

/// 構(gòu)造樹(shù)控件

/// </summary>

public void maketree()

{

clear();//清除樹(shù)節(jié)點(diǎn)中的資源

cursor.current =cursors.waitcursor ;

// 首先要給根節(jié)點(diǎn)付值,因?yàn)槿〕鰜?lái)的結(jié)構(gòu)中沒(méi)有根節(jié)點(diǎn)的信息

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>

/// 構(gòu)造一個(gè)動(dòng)態(tài)數(shù)組,模擬樹(shù)控件一個(gè)分叉的線(xiàn)性結(jié)構(gòu),每一次都是最新的線(xiàn)性結(jié)構(gòu),這整個(gè)控件關(guān)鍵地方

/// </summary>

/// <param name="strid">層次</param>

/// <param name="matid">物料編碼</param>

/// <param name="nodef">父節(jié)點(diǎn)</param>

/// <returns>構(gòu)造的節(jié)點(diǎn)</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;

}

}

}

}

經(jīng)過(guò)編譯就可以把控件bq_treeview添加進(jìn)來(lái),如下圖(圖2)


在應(yīng)用程序中只要

編寫(xiě)

bq_treeview1.rootmatid=strrootid;

bq_treeview1.treedatasource=tbproinfo;

bq_treeview1.maketree();

就可以顯示整個(gè)bom結(jié)構(gòu),tbproinfo為上面的sql語(yǔ)句取出的表結(jié)構(gòu)

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 民丰县| 屏南县| 青河县| 盐亭县| 定边县| 开平市| 武鸣县| 佛坪县| 安康市| 桦川县| 五家渠市| 枣强县| 湟中县| 留坝县| 白银市| 博兴县| 汉中市| 西峡县| 昂仁县| 湟中县| 济阳县| 友谊县| 马公市| 会同县| 廊坊市| 宜君县| 左云县| 太谷县| 黄浦区| 邛崃市| 大同县| 安康市| 彭阳县| 胶南市| 黄浦区| 阳新县| 泾川县| 灯塔市| 安陆市| 绥江县| 滁州市|