可以将 “窗体”和“dbgrid” 做参数传给函数吗? 可以,没什么不可以得。Delphi的类和C++的类不同。Delphi的类不过是一个引用,所以效率很高。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你为什么这么做呢?如果需要导出数据,直接把这个窗体DBGrid的数据DataSet传递给你的函数不就可以了吗? 传递TForm是可以的。下面是我的例子,可以让一个窗口震动一下。procedure shockWindow(AForm:TForm);var intX,intY,intLoop:integer; intOX,intOY:Integer;begin AForm.Refresh; intOX:=AForm.Left; intOY:=AForm.Top; intLoop:=5; while intLoop>0 do begin intX:=intOX-intLoop; intY:=intOY-intLoop; AForm.Left:=intX; AForm.Top:=intY; sleep(50); intX:=intOX-intLoop; intY:=intOY+intLoop; AForm.Left:=intX; AForm.Top:=intY; sleep(50); intX:=intOX+intLoop; intY:=intOY-intLoop; AForm.Left:=intX; AForm.Top:=intY; sleep(50); intX:=intOX+intLoop; intY:=intOY+intLoop; AForm.Left:=intX; AForm.Top:=intY; sleep(50); dec(intLoop,1); end; AForm.Left:=intOX; AForm.Top:=intOY;end;调用方法如下:shockWindow(Form名称) 如果你要实现对传入的TForm中的DBGrid直接引用是不可能的,你要引用DBGrid需要用到搜索传入的Form的Components。 procedure ShowForm(FormName:TForm);begin With FormName.Create(nil) do try ShowModal; finally Free; end;end; 多谢各位帮忙,问题大概解决:可以用如下方式定义和传递:定义过程: procedure userword(frm:tform;dt:dataset) begin ........ end;调用:var frm:tform; dt:tdataset;begin frm:=form2; dt:=table1; form1.userword(frm,dt) ;......end; 能否设置DBGrid的属性,使得其中的一列为密码样式 delphi2010里idudpserver接受数据怎么是乱码??? IDHTTP组件想修改cookie如何做到? 救命!急寻高手解决Intraweb问题 帮帮忙啦!(在线等...) sql server 建的库用delphi怎么打开? 如何防止输入同样的编号到数据库中(100分) Qick Report 的报表在win2k的打印问题 高难问题,大家快来 请问从文本文件中读的数据是string类型的,在插入到数据库前需要将类型转换成整形么? csdn应该要有在查询结果内搜索的功能! 大家晚上好,可以交个朋友吗? qq:15405747
你的函数不就可以了吗?
传递TForm是可以的。下面是我的例子,可以让一个窗口震动一下。
procedure shockWindow(AForm:TForm);
var
intX,intY,intLoop:integer;
intOX,intOY:Integer;
begin
AForm.Refresh;
intOX:=AForm.Left;
intOY:=AForm.Top;
intLoop:=5;
while intLoop>0 do
begin
intX:=intOX-intLoop;
intY:=intOY-intLoop;
AForm.Left:=intX;
AForm.Top:=intY;
sleep(50);
intX:=intOX-intLoop;
intY:=intOY+intLoop;
AForm.Left:=intX;
AForm.Top:=intY;
sleep(50);
intX:=intOX+intLoop;
intY:=intOY-intLoop;
AForm.Left:=intX;
AForm.Top:=intY;
sleep(50);
intX:=intOX+intLoop;
intY:=intOY+intLoop;
AForm.Left:=intX;
AForm.Top:=intY;
sleep(50);
dec(intLoop,1);
end;
AForm.Left:=intOX;
AForm.Top:=intOY;
end;调用方法如下:shockWindow(Form名称) 如果你要实现对传入的TForm中的DBGrid直接引用是不可能的,
你要引用DBGrid需要用到搜索传入的Form的Components。
begin
With FormName.Create(nil) do
try
ShowModal;
finally
Free;
end;
end;
可以用如下方式定义和传递:
定义过程: procedure userword(frm:tform;dt:dataset)
begin
........
end;
调用:
var frm:tform;
dt:tdataset;
begin
frm:=form2;
dt:=table1;
form1.userword(frm,dt) ;
......
end;