예전에 동적생성때문에 글을 올렷는데 아무도 답변을 안해주시더라구요 ㅠㅠ
아랜 쿼리랑 데이타소스 동적생성후 dbgrid 에 연결시키는겁니다.
참고하세요.
어느정도 배열값을 여유주고 했는데 배열값까지 동적이시라면
SetLength 해서 배열값 만드시고 하시면 될듯 싶네요..그럼.
var
F_PEOPLE_TOTAL_L: TF_PEOPLE_TOTAL_L;
Dynamicqry : array[1..99] of TQuery;
Dynamicds : array[1..99] of TDataSource;
DyNamicDBGrid : array[1..99] of TDBGrid;
procedure TF_PEOPLE_TOTAL_L.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
for i := 1 to 99 do
begin
DyNamicDBGrid[(iPageCount) - i].Free;
DynamicDs[(iPageCount) - i].Free;
DynamicQry[(iPageCount) - i].Close;
DynamicQry[(iPageCount) - i].Free;
end;
end;
for i := 0 to iPageCount - 1 do
begin
DyNamicDBGrid[(iPageCount) - i].Free;
DynamicDs[(iPageCount) - i].Free;
DynamicQry[(iPageCount) - i].Close;
DynamicQry[(iPageCount) - i].Free;
end;
for i := 0 to iPageCount - 1 do
begin
Gauge1.Progress := i + 1;
// 진행 정보 보기
DynamicQry[i + 1] := TQuery.Create(Self);
아랜 쿼리랑 데이타소스 동적생성후 dbgrid 에 연결시키는겁니다.
참고하세요.
어느정도 배열값을 여유주고 했는데 배열값까지 동적이시라면
SetLength 해서 배열값 만드시고 하시면 될듯 싶네요..그럼.
var
F_PEOPLE_TOTAL_L: TF_PEOPLE_TOTAL_L;
Dynamicqry : array[1..99] of TQuery;
Dynamicds : array[1..99] of TDataSource;
DyNamicDBGrid : array[1..99] of TDBGrid;
procedure TF_PEOPLE_TOTAL_L.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
for i := 1 to 99 do
begin
DyNamicDBGrid[(iPageCount) - i].Free;
DynamicDs[(iPageCount) - i].Free;
DynamicQry[(iPageCount) - i].Close;
DynamicQry[(iPageCount) - i].Free;
end;
end;
Action := CaFree;
end;
procedure TF_PEOPLE_TOTAL_L.OBtn_FindClick(Sender: TObject; iPageCount : Integer);
var
sFind_Part_Code : String;
begin
DBGrid1.Visible := False; //초기에 디자인한 dbgrid
Gauge1.Visible := True;
Gauge1.MaxValue := iPageCount ;
Gauge1.Progress := 0;
for i := 0 to iPageCount - 1 do
begin
DyNamicDBGrid[(iPageCount) - i].Free;
DynamicDs[(iPageCount) - i].Free;
DynamicQry[(iPageCount) - i].Close;
DynamicQry[(iPageCount) - i].Free;
end;
for i := 0 to iPageCount - 1 do
begin
Gauge1.Progress := i + 1;
// 진행 정보 보기
DynamicQry[i + 1] := TQuery.Create(Self);
DynamicQry[i + 1].Name := 'DynamicQry' + inttostr(i + 1);
DynamicQry[i + 1].DataBaseName := 'DBMAC'; //Qry_APCode.DataBaseName;
DynamicQry[i + 1].SQL.Clear;
DynamicQry[i + 1].SQL.Add( 'SELECT A.FINDYEAR, ' );
DynamicQry[i + 1].SQL.Add( '........... ' );
DynamicDS[i + 1] := TDataSource.Create(Self);
with DynamicDS[i + 1] do
DataSet := DynamicQry[i + 1];
DynamicDBGrid[i + 1] := TDBGrid.Create(Self);
with DynamicDBGrid[i + 1] do
begin
BeginUpdate;
DestroyColumns;
Align := alClient;
DataSource := DynamicDS[i + 1];
TabStop := False;
......
DefaultLayout := False;
EndUpdate;
CreateDBGridColumns(DynamicDBGrid[i + 1], DynamicQry[i + 1]);
DynamicQry[i + 1].Close;
DynamicQry[i + 1].Parambyname('FINDyear').asstring := SE_year.text;
DynamicQry[i + 1].Open;
DynamicQry[i + 1].First;
end;
end;
Gauge1.Visible := False;
end;
procedure TF_PEOPLE_TOTAL_L.CreateDBGridColumns(Grid :TDBGrid; Qry : TQuery);
var
DBGridColumn : TDBGridColumn;
begin
// 직급
DBGridColumn := TDBGridColumn.Create(Grid);
DBGridColumn.Name := Grid.Name + 'AP_CODE';
DBGridColumn.fieldName := 'AB_NAME';
DBGridColumn.Caption := '직급';
DBGridColumn.Width := 120;
.....
end;