L
Liangpei2008
Unregistered / Unconfirmed
GUEST, unregistred user!
怎么从数据库得到的动态查询结果(也就是表的列数,列名等)在dxdbgrid控件中动态生成和绑定列,(注:是永久性的添加)
function AdddxDBColumn(dxDBGrid:TdxDBGrid;FieldName,TitleCaption:String;Width:Integer=100): TDxDBGridColumn;
var
iWidth:Integer;
begin
Result := TDxDBGridColumn(dxDBGrid.CreateColumn(TdxDBGridColumn));
Result.FieldName := FieldName;
iWidth:=dxDBGrid.Canvas.TextWidth(TitleCaption)+10;
if iWidth<100 then Result.Width:=100 else Result.Width:=iWidth;
with Result do
begin
Alignment:=taCenter;
Caption:=TitleCaption;
Alignment:=taCenter;
BandIndex := 1;
end;
end;
--------------
这个函数可以临时添加和绑定列,但是重新启动程序后,新增的列就没了,恳求大哥们帮帮忙!
function AdddxDBColumn(dxDBGrid:TdxDBGrid;FieldName,TitleCaption:String;Width:Integer=100): TDxDBGridColumn;
var
iWidth:Integer;
begin
Result := TDxDBGridColumn(dxDBGrid.CreateColumn(TdxDBGridColumn));
Result.FieldName := FieldName;
iWidth:=dxDBGrid.Canvas.TextWidth(TitleCaption)+10;
if iWidth<100 then Result.Width:=100 else Result.Width:=iWidth;
with Result do
begin
Alignment:=taCenter;
Caption:=TitleCaption;
Alignment:=taCenter;
BandIndex := 1;
end;
end;
--------------
这个函数可以临时添加和绑定列,但是重新启动程序后,新增的列就没了,恳求大哥们帮帮忙!