我还想问一下各位,如果是一组动态的创建的parnel.和一组动态创建的SHAPE,二者创建的时间不是一定是同时的,当然panel肯定是在shape之前创建的,就是说要指明哪明某个SHAPE的PARENT是谁要怎么做?? 比如有若干个车间,每个车间有若干个机器,我用PANEL代表车间,用SHPAE代表机器,所以当我在车间一里增加机器时,那个shape的PARENT就要是车间一的对应的那个PANEL对吧
解决方案 »
- 你是什么时候开始使用Delphi的,为什么不用很多人认为很有前途的Java,C#……
- access数据库中的SQL代码怎样使用“*=“?
- delphi能给access数据库创建新表吗?
- 程序(界面是一个长条)启动后停靠在桌面最上方,怎么让我的电脑等图标自动往下移动?(
- 失恋了!狂痛!散分!
- 晕!!!!!!!!!!!!!!!
- 关于visio2002激活问题
- 问关于一个indy 中,idftp的问题
- 101分求解
- 怎样修改菜单中的背景颜色?
- delphi6.0--installshild 做安装文件时 安装后在windows内的新增,册除内看到的程序名是default,该在哪理改自已想要的名呢?
- 路径是否存在用什么判断??
创建shape时, 搜索机器所在车间id ,就得到panel 的tag了.
然后遍历比较tag
procedure TmainF.AddNodeClick(Sender: TObject);
var
selectnode: TTreeNode; //±»Ñ¡ÔñµÄ½Úµã
shape: tshape;
nonode: integer; //½Úµã±¾ÉíµÄºÅÊý
noname: string; //½ÚµãÃû³Æ
sqlstr: string; //sql ÊäÈëÓï¾ä
chileno: integer; //Ô­½ÚµãÖÐ×Ó½ÚµãµÄ¸öÊý
panelname: string;
shapename: string;
node_id: integer; //µ±Ç°½ÚµãµÄºÅÂë
panelno: integer;
ii: integer;
begin
selectnode := TreeView1.Selected;
nonode := TreeView1.Selected.Count; //(0<count<999)
panelno := 0;
// if (selectnode.Text = '´óÔ²»ú') or (selectnode.Parent.Text = '´óÔ²»ú') then begin
if (selectnode.Text = '´óÔ²»ú') then begin //Ìí¼Ó³µ¼äºÅ
noname := '³µ¼ä' + inttostr(nonode + 1);
try
begin
panelname := 'panel' + inttostr(nonode + 1);
panel[panelno] := tpanel.Create(RzPanel1); //Ìí¼ÓSHAPE
with panel[panelno] do begin
parent := mainF;
name := panelname;
left := 208;
TOP := 32;
height := 500;
width := 585;
BEVeLOUTER := BVLOWERED;
color := clCaptionText;
// visible:=false;
end;
end;
except
showmessage('Ìí¼Ó½Úµã³ö´í£¬ÇëÈ·ÈϺóÌí¼Ó£¡');
end;
end
else if (selectnode.parent.Text = '´óÔ²»ú') then begin
if (nonode > 8) and (nonode <= 98) then begin //Èç¹ûÉ豸̨Êý´óÓÚ9̨СÓÚµÈÓÚ98
if (length(selectnode.Text) = 5) then //³µ¼äºÅ¡´9
noname := 'NO' + '0' + copy(selectnode.Text, length(selectnode.Text), 1) + '0' + inttostr(nonode + 1)
else if (length(selectnode.Text) = 6) then //³µ¼äºÅ>9
noname := 'NO' + copy(selectnode.Text, length(selectnode.Text) - 1, 2) + '0' + inttostr(nonode + 1);
end
else if nonode <= 8 then begin //Èç¹ûÉ豸̨ÊýСÓÚ9̨
if (length(selectnode.Text) = 5) then //³µ¼äºÅ¡´9
noname := 'NO' + '0' + copy(selectnode.Text, length(selectnode.Text), 1) + '00' + inttostr(nonode + 1)
else if (length(selectnode.Text) = 6) then //³µ¼äºÅ>9
noname := 'NO' + copy(selectnode.Text, length(selectnode.Text) - 1, 2) + '00' + inttostr(nonode + 1);
end
else if nonode > 98 then begin //Èç¹ûÉ豸̨Êý´óÓÚ98̨
if (length(selectnode.Text) = 5) then //³µ¼äºÅ¡´9
noname := 'NO' + '0' + copy(selectnode.Text, length(selectnode.Text), 1) + inttostr(nonode + 1)
else if (length(selectnode.Text) = 6) then //³µ¼äºÅ>9
noname := 'NO' + copy(selectnode.Text, length(selectnode.Text) - 1, 2) + inttostr(nonode + 1);
end;
try
begin
shapename := copy(noname, 2, length(noname) - 1);
shape := tshape.Create(self);
with shape do begin
parent := panel[nonode + 1];
// parent:=self;
name := shapename;
left := 30;
TOP := 30;
height := 300;
width := 300;
shape := stCircle;
brush.color := cllime;
brush.Style := bssolid;
end;
// showmessage(panel[nonode+1].Parent.name );
end;
except
showmessage('½ÚµãÌí¼Ó³ö´í£¬ÇëÈ·ÈϺóÌí¼Ó£¡');
end;
end;
end;
这是我创建SHAPE和panel的代码,请各位看看现在shape有创建,可是看不到,为什么呢?????
procedure TmainF.AddNodeClick(Sender: TObject);
var
noname: string;
panelname: string;
shapename: string;
panelno: integer;
ii: integer;
begin
selectnode := TreeView1.Selected;
nonode := TreeView1.Selected.Count; //(0<count<999)
panelno := 0;
if (selectnode.Text = '´óÔ²»ú') then begin //这也只是一个添加nonode_name 的地方
noname := '³µ¼ä' + inttostr(nonode + 1);
try
begin
panelname := 'panel' + inttostr(nonode + 1);
panel[panelno] := tpanel.Create(RzPanel1); //Ìí¼ÓSHAPE
with panel[panelno] do begin
parent := mainF;
name := panelname;
left := 208;
TOP := 32;
height := 500;
width := 585;
BEVeLOUTER := BVLOWERED;
color := clCaptionText;
// visible:=false;
end;
end;
except
showmessage('Ìí¼Ó½Úµã³ö´í£¬ÇëÈ·ÈϺóÌí¼Ó£¡');
end;
end
else if (selectnode.parent.Text = '´óÔ²»ú') then begin
nonode_name:= //这儿只是一个添加nonode_name 的地方
end;
try
begin
shapename := copy(noname, 2, length(noname) - 1);
shape := tshape.Create(self);
with shape do begin
parent := panel[nonode + 1];
// parent:=self;
name := shapename;
left := 30;
TOP := 30;
height := 300;
width := 300;
shape := stCircle;
brush.color := cllime;
brush.Style := bssolid;
end;
// showmessage(panel[nonode+1].Parent.name );
TreeView1.Items.AddChild(selectnode, noname);
end;
except
showmessage('½ÚµãÌí¼Ó³ö´í£¬ÇëÈ·ÈϺóÌí¼Ó£¡');
end;
end;
end;
我的PANEL和shape 不是同时创建的,所以把shape定父亲的时候老是出错。
shape.parent := panel
to 无风雪亦飘 我的SHAPE和PANEL不是同一个时候创建的
能不能具体一点