{"id":726,"date":"2008-05-23T11:08:12","date_gmt":"2008-05-23T11:08:12","guid":{"rendered":"http:\/\/6teen.ru\/?p=589"},"modified":"2008-05-23T11:08:12","modified_gmt":"2008-05-23T11:08:12","slug":"2669","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=726","title":{"rendered":"\u041f\u0435\u0447\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e DBGrid \u0447\u0435\u0440\u0435\u0437 QuickReport"},"content":{"rendered":"<p>\u041f\u0435\u0447\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e DBGrid \u0447\u0435\u0440\u0435\u0437 QuickReport<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u041f\u0435\u0447\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e DBGrid \u0447\u0435\u0440\u0435\u0437 QuickReport\n\n\u0410\u0432\u0442\u043e\u0440: Rafael Ribas Aguil\u0443\n\n\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c: Delphi 3.x (\u0438\u043b\u0438 \u0432\u044b\u0448\u0435)\n\n\u0427\u0430\u0441\u0442\u0435\u043d\u044c\u043a\u043e \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u043e\u0442\u0447\u0451\u0442 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u043e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0412\u0430\u0441 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 TQuickRep \u0434\u0430\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0448\u0438\u0442\u044c.\n\n\u0418\u0442\u0430\u043a, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u0443\u044e \u0444\u043e\u0440\u043c\u0443, \u043d\u0430\u0437\u0432\u0430\u0432 \u0435\u0451 TGridReport, \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u0435 \u043d\u0430 \u043d\u0435\u0451 TQuickRep. \u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0439\u0442\u0435 QuickRep \u0432 GridRep. \u0417\u0430\u0442\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u044e\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 DBGrid:\n\nprocedure TGridReport.Preview(Grid: TDBGrid);\nvar\n  i, CurrentLeft, CurrentTop : integer;\n  BMark: TBookmark;\nbegin\n  GridRep.Dataset:=Grid.DataSource.DataSet;\n  if not GridRep.Bands.HasColumnHeader then\n    GridRep.Bands.HasColumnHeader:=true;\n  if not GridRep.Bands.HasDetail then\n    GridRep.Bands.HasDetail:=true;\n  GridRep.Bands.ColumnHeaderBand.Height:=Abs(Grid.TitleFont.Height) + 10;\n  GridRep.Bands.DetailBand.Height:=Abs(Grid.Font.Height) + 10;\n  CurrentLeft := 12;\n  CurrentTop := 6;\n  {\u0417\u0430\u043f\u0438\u0441\u044c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 DBGrid}\n  BMark:=Grid.DataSource.DataSet.GetBookmark;\n  {\u0417\u0430\u043f\u0440\u0435\u0442\u0438\u043c \u043c\u0435\u0440\u0446\u0430\u043d\u0438\u0435 \u0433\u0440\u0438\u0434\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0442\u0447\u0451\u0442\u0430}\n  Grid.DataSource.DataSet.DisableControls;\n  try\n    for i:=0 to Grid.FieldCount - 1 do\n    begin\n      if (CurrentLeft + Canvas.TextWidth(Grid.Columns[i].Title.Caption)) >\n        (GridRep.Bands.ColumnHeaderBand.Width) then\n      begin\n        CurrentLeft := 12;\n        CurrentTop := CurrentTop + Canvas.TextHeight('A') + 6;\n        GridRep.Bands.ColumnHeaderBand.Height := GridRep.Bands.ColumnHeaderBand.Height +\n          (Canvas.TextHeight('A') + 10);\n        GridRep.Bands.DetailBand.Height := GridRep.Bands.DetailBand.Height +\n          (Canvas.TextHeight('A') + 10);\n      end;\n      {\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043e\u0442\u0447\u0451\u0442\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 QRLabels}\n      with TQRLabel.Create(GridRep.Bands.ColumnHeaderBand) do\n      begin\n        Parent := GridRep.Bands.ColumnHeaderBand;\n        Color := GridRep.Bands.ColumnHeaderBand.Color;\n        Left := CurrentLeft;\n        Top := CurrentTop;\n        Caption:=Grid.Columns[i].Title.Caption;\n      end;\n      {\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0435\u043b\u043e \u043e\u0442\u0447\u0451\u0442\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 QRDBText}\n      with TQRDbText.Create(GridRep.Bands.DetailBand) do\n      begin\n        Parent := GridRep.Bands.DetailBand;\n        Color := GridRep.Bands.DetailBand.Color;\n        Left := CurrentLeft;\n        Top := CurrentTop;\n        Alignment:=Grid.Columns[i].Alignment;\n        AutoSize:=false;\n        AutoStretch:=true;\n        Width:=Grid.Columns[i].Width;\n        Dataset:=GridRep.Dataset;\n        DataField:=Grid.Fields[i].FieldName;\n        CurrentLeft:=CurrentLeft + (Grid.Columns[i].Width) + 15;\n      end;\n    end;\n    lblPage.Left := bdTitle.Width - lblPage.Width - 10;\n    lblDate.Left := bdTitle.Width - lblDate.Width - 10;\n    {\u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0438\u0437 QuickRep}\n    GridRep.PreviewModal; {\u043b\u0438\u0431\u043e, \u0435\u0441\u043b\u0438 \u0436\u0435\u043b\u0430\u0435\u0442\u0435, \u0442\u043e PreviewModal}\n  finally\n    with Grid.DataSource.DataSet do\n    begin\n      GotoBookmark(BMark);\n      FreeBookmark(BMark);\n      EnableControls;\n    end;\n  end;\nend;\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0435\u0447\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e DBGrid \u0447\u0435\u0440\u0435\u0437 QuickReport<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[401,386],"tags":[1906,1171,281,1743],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/726"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=726"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/726\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=726"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}