T
twquac
Unregistered / Unconfirmed
GUEST, unregistred user!
几天无人问律的问题,想问问各位高手,这题难吗?还是各位看到分数少?如果是因为分少的话,我可以开另外一个贴子送分,只求各位说句话。(在线等待) ( 积分: 40 )<br />function Createdxdbgdcol(aApp:TApplication;DllScr:TScreen;Mydataset:TDataSet;
Mydxdbgd:TdxDBGrid):boolean;stdcall;
var
i,n:integer;
Newbands:TdxTreeListBand;
begin
CoInitialize(Nil);
Application:=aApp;
Screen:=DllScr;
for i:=0 to Mydxdbgd.ColumnCount-1 do
Mydxdbgd.Columns[0].Destroy ;
//建立两个band,一个为显示锁定列,另一个为显示非锁定列
for i:=0 to Mydxdbgd.Bands.Count-1 do
Mydxdbgd.Bands[0].Destroy;
Newbands:=Mydxdbgd.Bands.Add;
Newbands.MinWidth :=0;
Newbands.Width :=0;
Newbands.Fixed :=bfLeft;
Newbands:=Mydxdbgd.Bands.Add;
n:=0;
for i:=0 to Mydataset.FieldCount-1 do
begin
if MydataSet.Fields.Visible =False then
Continue
else
begin
//建立列
[red]Mydxdbgd.CreateColumn(TdxDBGridColumn);[/red] //设置列
Mydxdbgd.Columns[n].BandIndex :=1;
Mydxdbgd.Columns[n].FieldName :=Mydataset.Fields.FieldName;
Mydxdbgd.Columns[n].Caption :=Mydataset.Fields.DisplayLabel ;
Inc
;
end;
end;
end;
我把创建dxdbgrid控件列的代码写入DLL中,可每次调用时一执行到Mydxdbgd.CreateColumn(TdxDBGridColumn)就出错,错误提示为:invalid class typecast,这是为什么?
Mydxdbgd:TdxDBGrid):boolean;stdcall;
var
i,n:integer;
Newbands:TdxTreeListBand;
begin
CoInitialize(Nil);
Application:=aApp;
Screen:=DllScr;
for i:=0 to Mydxdbgd.ColumnCount-1 do
Mydxdbgd.Columns[0].Destroy ;
//建立两个band,一个为显示锁定列,另一个为显示非锁定列
for i:=0 to Mydxdbgd.Bands.Count-1 do
Mydxdbgd.Bands[0].Destroy;
Newbands:=Mydxdbgd.Bands.Add;
Newbands.MinWidth :=0;
Newbands.Width :=0;
Newbands.Fixed :=bfLeft;
Newbands:=Mydxdbgd.Bands.Add;
n:=0;
for i:=0 to Mydataset.FieldCount-1 do
begin
if MydataSet.Fields.Visible =False then
Continue
else
begin
//建立列
[red]Mydxdbgd.CreateColumn(TdxDBGridColumn);[/red] //设置列
Mydxdbgd.Columns[n].BandIndex :=1;
Mydxdbgd.Columns[n].FieldName :=Mydataset.Fields.FieldName;
Mydxdbgd.Columns[n].Caption :=Mydataset.Fields.DisplayLabel ;
Inc
![Thumbs down (n) (n)](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f44e.png)
end;
end;
end;
我把创建dxdbgrid控件列的代码写入DLL中,可每次调用时一执行到Mydxdbgd.CreateColumn(TdxDBGridColumn)就出错,错误提示为:invalid class typecast,这是为什么?