delphi 实现组织机构图的显示!!!! 直接导出WORD也行,类似以下图形,
其中单位和部门需要用矩形框 框起来,其中部门不是固定的,部门可以增加,
增加部门后,也要显示出来 |-部门A
|-魏国 --|-部门B
| |-部门C
三国集团-|-吴国
| |-部门D
|-蜀国 --|-部门E
|-部门F
其中单位和部门需要用矩形框 框起来,其中部门不是固定的,部门可以增加,
增加部门后,也要显示出来 |-部门A
|-魏国 --|-部门B
| |-部门C
三国集团-|-吴国
| |-部门D
|-蜀国 --|-部门E
|-部门F
想要横过来的treeview?
建议楼主使用DevExpress的TdxDbOrgChart控件,该控件就是为这方面而写出来的。
本人写过一个该控件应用的例子,你如果需要代码,请到中国软件研发联盟QQ群122058606的共享空间下载“DEV感知数据流程图简例6.rar”。
treeview后跟n个子节点都可以啊
内容少的时候,OrgChart很好看,多了就很占位置
当然,如果更多,treeview也看不过来了
有个从C转过来的,很强悍:unit UnitSuduByC;interfacefunction suduByC(s:String):String;var
cc:Integer=0; //step no
step:String='';implementationuses UnitLn, SysUtils;const
cn=9;
c:array [0..cn] of Integer=(0,$1,$2,$4,$8,$10,$20,$40,$80,$100);
var
a:array [0..cn*cn-1] of Integer;
b:array [0..cn*3-1] of Integer;function M(g,k:Integer):Integer;
begin
// (b[g%9]|b[(g/9)+9]|b[18+(g/27)*3+((g%9)/3)])&c[k]
Result:= (b[g mod 9] or b[(g div 9)+9] or b[18+(g div 27)*3+((g mod 9) div 3)])
and c[k];
end;
function L(g,k:Integer):Integer;
begin
//b[g%9]^=c[k],b[(g/9)+9]^=c[k],b[18+(g/27)*3+((g%9)/3)]^=c[k]
Result:=0;
b[g mod 9]:=b[g mod 9] xor c[k];
b[(g div 9)+9]:=b[(g div 9)+9] xor c[k];
g:=18+(g div 27)*3+((g mod 9) div 3);
b[g]:=b[g] xor c[k];
end;
function t(i,p:Integer):Integer;
var
k:Integer;
begin
if cc>-1 then
Begin
Inc(cc);
step:=step+ln+format('%d=%d:%d[',[cc,i,p]);
End; while (p<cn*cn) and (a[p]<>0) do
inc(p); Result:=0;
if (i>cn*cn) then
Begin
Result:=1;
if cc>-1 then
Begin
Inc(cc);
step:=step+ln+format('%d=%d:%d]1.',[cc,i,p]);
End; exit; //got it
End; for k:=9 downto 1 do
if M(p,k)=0 then
Begin
a[p]:=k;
L(p,k);
if t(i+1,p+1)<>0 then
Begin
Result:=1;
//exit; //got it
break;
End;
a[p]:=0;
L(p,k);
End; if cc>-1 then
Begin
//Inc(cc);
step:=step+ln+format('%d=%d:%d]%d',[cc,i,p,result]);
End;
//result:=0;
end;function suduByC(s:String):String;
var
i,n, j,k:Integer;
begin
result:='';
step:='';
if cc>0 then
cc:=0; for i:=Low(b) to High(b) do
b[i]:=0;
for i:=Low(a) to High(a) do
a[i]:=0; j:=0;
k:=1; n:=0;
for i:=1 to Length(s) do
Begin
if not (s[i] in ['0'..'9']) then
Continue;
Inc(n);
if n>cn*cn then
Break;
a[n-1]:=Ord(s[i])-ord('0');
if a[n-1]<>0 then
Begin
L(n-1,a[n-1]);
Inc(k);
End;
end; if n<cn*cn then
exit; for j:=cn*cn downto 1 do
step:=step+chr(Ord('0')+a[cn*cn-j]);
step:=step+ln; t(k,0); for j:=cn*cn downto 1 do
result:=result+chr(Ord('0')+a[cn*cn-j]);end;
end.(*
#include<stdio.h>
#define TEST_NUM4 "000" "600" "142"\
"026" "000" "000"\
"700" "004" "009"\
\
"000" "006" "200"\
"060" "901" "050"\
"005" "300" "000"\
\
"900" "400" "007"\
"000" "000" "810"\
"842" "007" "000"
const int c[10] = {0x0,0x1,0x2,0x4,0x8,0x10,0x20,0x40,0x80,0x100};
int a[81];
int b[27];int cc=0;#define M(g,k) (b[g%9]|b[(g/9)+9]|b[18+(g/27)*3+((g%9)/3)])&c[k]
#define L(g,k) b[g%9]^=c[k],b[(g/9)+9]^=c[k],b[18+(g/27)*3+((g%9)/3)]^=c[k]
int t(int i,int p)
{
int k;
if(i>81){
// putA();
return 1;/** got it */
}
while(p<81&&a[p])p++;printf("%d=%d %d\n",++cc,i,p); for(k=9;k;--k){
if(!(M(p,k))){
a[p]=k;
L(p,k);
if(t(i+1,p+1)) return 1;
a[p]=0;
L(p,k);
}
} return 0;
}main(int i, char **x)
{
const char *pcFunc= TEST_NUM4;
int j=0,k=1;
if (i>1)
pcFunc=x[1];
for(;*pcFunc;pcFunc++,j++){/** init */
if (a[j]=*pcFunc-'0'){
L(j,a[j]);
k++;
}
}
t(k,0);/** get */
for(j=81;j--;){
printf("%d%c",a[80-j],j%9?' ':'\n');
}
return 0;
}*)