公司要做一個組織結構圖,或者是叫思維導圖,然后在網上找了很多,終於找到了一個合適的C#組織結構圖控件。
先把圖展示給出來看看效果:
水平:

垂直:

使用方法:
1.在網站或Web應用程序中引用dll后,頁面寫法:
<%@ Page Language=
"
C#
" AutoEventWireup=
"
true
" CodeBehind=
"
MyTest.aspx.cs
" Inherits=
"
OrgChartWebControl.Gallery.MyTest
" %>
<%@ Register TagPrefix= " oc " Namespace= " Whidsoft.WebControls " Assembly= " Whidsoft.WebControls.OrgChart " %>
<html>
<head runat= " server ">
<title>思維導圖</title>
<style type= " text/css ">
.alink a,a:hover,a:visited{
color:Black;
text-decoration:none;
}
</style>
</head>
<body>
<form id= " Form1 " method= " post " runat= " server ">
<div class= " alink ">
<oc:orgchart id= " OrgChart1 " style= " z-index: 101; left: 104px; position: absolute; top: 88px "
runat= " server " LineColor= " Silver " Width= " 100% " Height= " 100% " ChartStyle= " Vertical " ToolTip= " test "></oc:orgchart>
</div>
</form>
</body>
</html>
<%@ Register TagPrefix= " oc " Namespace= " Whidsoft.WebControls " Assembly= " Whidsoft.WebControls.OrgChart " %>
<html>
<head runat= " server ">
<title>思維導圖</title>
<style type= " text/css ">
.alink a,a:hover,a:visited{
color:Black;
text-decoration:none;
}
</style>
</head>
<body>
<form id= " Form1 " method= " post " runat= " server ">
<div class= " alink ">
<oc:orgchart id= " OrgChart1 " style= " z-index: 101; left: 104px; position: absolute; top: 88px "
runat= " server " LineColor= " Silver " Width= " 100% " Height= " 100% " ChartStyle= " Vertical " ToolTip= " test "></oc:orgchart>
</div>
</form>
</body>
</html>
后台代碼使用寫法:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Whidsoft.WebControls;
namespace OrgChartWebControl.Gallery
{
/* ---------------------------------------------
* 頁面描述:
* 創建人:shopping
* 創建日期:2012-5-4 14:57:28
* 公司名稱:
--------------------------------------------- */
public partial class MyTest : System.Web.UI.Page
{
protected void Page_Load( object sender, EventArgs e)
{
string style = Request.QueryString[ " style "];
if (style == null || style == "")
{
style = " 1 ";
}
if (!IsPostBack)
{
// 每一個組織圖中的節點都是一個OrgNode,各屬性分別為顯示名稱,tips
OrgNode orgNode = new OrgNode();
orgNode.Text = " 羅寶線 ";
orgNode.Description = " 這是組織圖的塔尖 ";
orgNode.NavigateUrl = " http://www.whidsoft.cn ";
orgNode.UnderDesc = " 累計電度:1000萬度,占線路用電 100% ";
// 建立各節點
OrgNode OrgNode1 = new OrgNode();
OrgNode1.Text = " 車站照明動力 ";
OrgNode1.Description = " 這是 ";
OrgNode1.UnderDesc = " 累計電度:55萬度,占線路用電 65% ";
OrgNode OrgNode11 = new OrgNode();
OrgNode11.Text = " 車站1 ";
OrgNode11.Description = " 這是 ";
OrgNode11.UnderDesc = " 累計電度:33萬度,占線路用電 13% ";
OrgNode OrgNode12 = new OrgNode();
OrgNode12.Text = " 車站2 ";
OrgNode12.Description = " 這是 ";
OrgNode12.UnderDesc = " 累計電度:133萬度,占線路用電 33% ";
OrgNode OrgNode13 = new OrgNode();
OrgNode13.Text = " 車站3 ";
OrgNode13.Description = " 這是 ";
OrgNode13.UnderDesc = " 累計電度:13萬度,占線路用電 33% ";
OrgNode1.Nodes.Add(OrgNode11);
OrgNode1.Nodes.Add(OrgNode12);
OrgNode1.Nodes.Add(OrgNode13);
orgNode.Nodes.Add(OrgNode1);
OrgNode OrgNode2 = new OrgNode();
OrgNode2.Text = " 牽引動力 ";
OrgNode2.Description = " 這是 ";
OrgNode2.UnderDesc = " 累計電度:13萬度,占線路用電 11% ";
OrgNode OrgNode21 = new OrgNode();
OrgNode21.Text = " 1段牽引 ";
OrgNode21.Description = " 這是 ";
OrgNode OrgNode22 = new OrgNode();
OrgNode22.Text = " 2段牽引 ";
OrgNode22.Description = " 這是 ";
OrgNode2.Nodes.Add(OrgNode21);
OrgNode2.Nodes.Add(OrgNode22);
orgNode.Nodes.Add(OrgNode2);
OrgNode OrgNode3 = new OrgNode();
OrgNode3.Text = " 維修段 ";
OrgNode3.Description = " 這是3 ";
OrgNode3.UnderDesc = " 累計電度:345萬度,占線路用電 54% ";
OrgNode OrgNode31 = new OrgNode();
OrgNode31.Text = " 檢修 ";
OrgNode31.Description = " 這是3 ";
OrgNode OrgNode32 = new OrgNode();
OrgNode32.Text = " 洗車及污水 ";
OrgNode32.Description = " 這是3 ";
OrgNode OrgNode33 = new OrgNode();
OrgNode33.Text = " 綜合辦公樓 ";
OrgNode33.Description = " 這是3 ";
OrgNode3.Nodes.Add(OrgNode31);
OrgNode3.Nodes.Add(OrgNode32);
OrgNode3.Nodes.Add(OrgNode33);
orgNode.Nodes.Add(OrgNode3);
OrgNode OrgNode4 = new OrgNode();
OrgNode4.Text = " 管理中心 ";
OrgNode4.Description = " 這是3 ";
OrgNode4.UnderDesc = " 累計電度:234萬度,占線路用電 34% ";
OrgNode OrgNode41 = new OrgNode();
OrgNode41.Text = " 辦公 ";
OrgNode41.Description = " 這是3 ";
OrgNode OrgNode42 = new OrgNode();
OrgNode42.Text = " 商業 ";
OrgNode42.Description = " 這是3 ";
OrgNode OrgNode43 = new OrgNode();
OrgNode43.Text = " 機房 ";
OrgNode43.Description = " 這是3 ";
OrgNode4.Nodes.Add(OrgNode41);
OrgNode4.Nodes.Add(OrgNode42);
OrgNode4.Nodes.Add(OrgNode43);
orgNode.Nodes.Add(OrgNode4);
OrgChart1.Node = orgNode;
OrgChart1.ChartStyle = (style == " 1 ") ? Whidsoft.WebControls.Orientation.Vertical : Whidsoft.WebControls.Orientation.Horizontal;
}
}
}
}
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Whidsoft.WebControls;
namespace OrgChartWebControl.Gallery
{
/* ---------------------------------------------
* 頁面描述:
* 創建人:shopping
* 創建日期:2012-5-4 14:57:28
* 公司名稱:
--------------------------------------------- */
public partial class MyTest : System.Web.UI.Page
{
protected void Page_Load( object sender, EventArgs e)
{
string style = Request.QueryString[ " style "];
if (style == null || style == "")
{
style = " 1 ";
}
if (!IsPostBack)
{
// 每一個組織圖中的節點都是一個OrgNode,各屬性分別為顯示名稱,tips
OrgNode orgNode = new OrgNode();
orgNode.Text = " 羅寶線 ";
orgNode.Description = " 這是組織圖的塔尖 ";
orgNode.NavigateUrl = " http://www.whidsoft.cn ";
orgNode.UnderDesc = " 累計電度:1000萬度,占線路用電 100% ";
// 建立各節點
OrgNode OrgNode1 = new OrgNode();
OrgNode1.Text = " 車站照明動力 ";
OrgNode1.Description = " 這是 ";
OrgNode1.UnderDesc = " 累計電度:55萬度,占線路用電 65% ";
OrgNode OrgNode11 = new OrgNode();
OrgNode11.Text = " 車站1 ";
OrgNode11.Description = " 這是 ";
OrgNode11.UnderDesc = " 累計電度:33萬度,占線路用電 13% ";
OrgNode OrgNode12 = new OrgNode();
OrgNode12.Text = " 車站2 ";
OrgNode12.Description = " 這是 ";
OrgNode12.UnderDesc = " 累計電度:133萬度,占線路用電 33% ";
OrgNode OrgNode13 = new OrgNode();
OrgNode13.Text = " 車站3 ";
OrgNode13.Description = " 這是 ";
OrgNode13.UnderDesc = " 累計電度:13萬度,占線路用電 33% ";
OrgNode1.Nodes.Add(OrgNode11);
OrgNode1.Nodes.Add(OrgNode12);
OrgNode1.Nodes.Add(OrgNode13);
orgNode.Nodes.Add(OrgNode1);
OrgNode OrgNode2 = new OrgNode();
OrgNode2.Text = " 牽引動力 ";
OrgNode2.Description = " 這是 ";
OrgNode2.UnderDesc = " 累計電度:13萬度,占線路用電 11% ";
OrgNode OrgNode21 = new OrgNode();
OrgNode21.Text = " 1段牽引 ";
OrgNode21.Description = " 這是 ";
OrgNode OrgNode22 = new OrgNode();
OrgNode22.Text = " 2段牽引 ";
OrgNode22.Description = " 這是 ";
OrgNode2.Nodes.Add(OrgNode21);
OrgNode2.Nodes.Add(OrgNode22);
orgNode.Nodes.Add(OrgNode2);
OrgNode OrgNode3 = new OrgNode();
OrgNode3.Text = " 維修段 ";
OrgNode3.Description = " 這是3 ";
OrgNode3.UnderDesc = " 累計電度:345萬度,占線路用電 54% ";
OrgNode OrgNode31 = new OrgNode();
OrgNode31.Text = " 檢修 ";
OrgNode31.Description = " 這是3 ";
OrgNode OrgNode32 = new OrgNode();
OrgNode32.Text = " 洗車及污水 ";
OrgNode32.Description = " 這是3 ";
OrgNode OrgNode33 = new OrgNode();
OrgNode33.Text = " 綜合辦公樓 ";
OrgNode33.Description = " 這是3 ";
OrgNode3.Nodes.Add(OrgNode31);
OrgNode3.Nodes.Add(OrgNode32);
OrgNode3.Nodes.Add(OrgNode33);
orgNode.Nodes.Add(OrgNode3);
OrgNode OrgNode4 = new OrgNode();
OrgNode4.Text = " 管理中心 ";
OrgNode4.Description = " 這是3 ";
OrgNode4.UnderDesc = " 累計電度:234萬度,占線路用電 34% ";
OrgNode OrgNode41 = new OrgNode();
OrgNode41.Text = " 辦公 ";
OrgNode41.Description = " 這是3 ";
OrgNode OrgNode42 = new OrgNode();
OrgNode42.Text = " 商業 ";
OrgNode42.Description = " 這是3 ";
OrgNode OrgNode43 = new OrgNode();
OrgNode43.Text = " 機房 ";
OrgNode43.Description = " 這是3 ";
OrgNode4.Nodes.Add(OrgNode41);
OrgNode4.Nodes.Add(OrgNode42);
OrgNode4.Nodes.Add(OrgNode43);
orgNode.Nodes.Add(OrgNode4);
OrgChart1.Node = orgNode;
OrgChart1.ChartStyle = (style == " 1 ") ? Whidsoft.WebControls.Orientation.Vertical : Whidsoft.WebControls.Orientation.Horizontal;
}
}
}
}
源碼下載:點擊下載控件源碼
發表該文章主要是用於個人學習收藏,轉載請著名出處,謝謝!
