procedure FillTitle(StrGrid: TStringGrid;
DataS: TDataSource;
FileName, TableName, FilterString: string);
var
I: Integer;
TempStr: Variant;
iniTemp: TIniFile;
begin
if not FileExists(ExtractFilePath(Application.ExeName) + FileName) then
begin
Application.MessageBox(PChar('配置文件丢失:' + ExtractFilePath(Application.ExeName) + FileName), '错误', MB_ICONERROR + MB_OK);
halt;
end
else
begin
iniTemp := nil;
try
iniTemp := TIniFile.Create(ExtractFilePath(Application.ExeName) + FileName);
except
Application.MessageBox(PChar('无法读取配置文件:' + ExtractFilePath(Application.ExeName) + FileName), '错误', MB_ICONERROR + MB_OK);
iniTemp.Free;
Application.Terminate;
end;
with StrGriddo
begin
ColCount := DataS.DataSet.FieldCount + 1;
ColWidths[0] := 18;
//第一列宽度
for I := 1 to ColCount - 1do
begin
// if DataS.DataSet.Fields.Fields[i - 1].DisplayName <> 'GUID' then
// begin
TempStr := 'SC_QUARTER_dbs_' + DataS.DataSet.Fields.Fields[i - 1].DisplayName;
Cells[i, 0] := iniTemp.ReadString(TableName, TempStr, '');
// end ;
end;
end;
iniTemp.Free;
//释放ini资源
end;
end;
procedure FillData(StrGrid: TStringGrid;
DataS: TDataSource);
//Fill Data
var
I, J: Integer;
begin
j := 1;
with StrGriddo
begin
while not DataS.DataSet.Eofdo
begin
for I := 1 to ColCount - 1do
Cells[i, j] := DataS.DataSet.Fields.Fields[i - 1].AsString;
j := j + 1;
DataS.DataSet.Next;
end;
end
end;
更多内容请联系阿拉 yzdbs#msn.com