Код
procedure TfrmRabot.ReBuildGrid;
const
DefaultRowHeight = 64;
FirstRowHeight = 32;
procedure AddItem(Kod, IsSogl: Integer);
var
tmp: Integer;
begin
tmp := Length(rabotArr);
SetLength(rabotArr, tmp + 1);
rabotArr[tmp].Kod := Kod;
rabotArr[tmp].IsSogl := IsSogl;
end;
var
row: Integer;
begin
isChanged := False;
AddItem(-1, -1);
sgRabot.ClearAll;
sgRabot.GridLineColor := clBlack;
sgRabot.GridFixedLineColor := clBlack;
sgRabot.ColCount := 5;
sgRabot.FixedRows := 1;
sgRabot.FixedCols := 0;
sgRabot.VAlignment := vtaCenter;
sgRabot.DefaultRowHeight := DefaultRowHeight;
sgRabot.RowHeights[0] := FirstRowHeight;
sgRabot.Cells[0, 0] :='Код работы';
sgRabot.Alignments[0, 0] := taCenter;
sgRabot.ColWidths[0] := 90;
sgRabot.WordWraps[0, 0] := False;
sgRabot.Cells[1, 0] :='Наименование работы';
sgRabot.Alignments[1, 0] := taCenter;
sgRabot.ColWidths[1] := 380;
sgRabot.WordWraps[1, 0] := False;
sgRabot.Cells[2, 0] :='Наименование группы';
sgRabot.Alignments[2, 0] := taCenter;
sgRabot.ColWidths[2] := 300;
sgRabot.WordWraps[2, 0] := False;
sgRabot.Cells[3, 0] :='Ремонт / замена';
sgRabot.Alignments[3, 0] := taCenter;
sgRabot.ColWidths[3] := 80;
sgRabot.WordWraps[3, 0] := True;
sgRabot.Cells[4, 0] :='Согласовано / запрещено';
sgRabot.Alignments[4, 0] := taCenter;
sgRabot.ColWidths[4] := 100;
sgRabot.WordWraps[4, 0] := True;
sgRabot.Multilinecells:=true;
sgRabot.WordWrap:=true;
DM.GetRabot;
sgRabot.RowCount := DM.qryRabot.RecordCount + 1;
row := 1;
while not DM.qryRabot.Eof do
begin
sgRabot.Cells[0, row]:= DM.qryRabot.FieldByName('Nomer').AsString;
sgRabot.Alignments[0, row] := taCenter;
sgRabot.Cells[1, row]:= DM.qryRabot.FieldByName('Name_Rab').AsString;
sgRabot.Alignments[1, row] := taLeftJustify;
sgRabot.WordWraps[1, row] := True;
sgRabot.Cells[2, row]:= DM.qryRabot.FieldByName('Name_Group').AsString;
sgRabot.Alignments[2, row] := taLeftJustify;
sgRabot.WordWraps[2, row] := True;
if DM.qryRabot.FieldByName('Priznak_Rem').AsInteger = 1 then
sgRabot.Cells[3, row] := 'Ремонт'
else
sgRabot.Cells[3, row] := 'Замена';
sgRabot.Alignments[3, row] := taCenter;
if DM.qryRabot.FieldByName('Priznak_Sol').AsInteger = 1 then
sgRabot.Cells[4, row] := 'Согласовано'
else
sgRabot.Cells[4, row] := 'Запрещено';
sgRabot.Alignments[4, row] := taCenter;
AddItem(
DM.qryRabot.FieldByName('Kod').AsInteger,
DM.qryRabot.FieldByName('Priznak_Sol').AsInteger
);
sgRabot.AutoSizeRow(row);
Inc(row);
DM.qryRabot.Next;
end;
DM.qryRabot.Close;
end;