StrinfGrid의 내용을 인쇄코드를 짜려고 합니다(퀵레포트 이용해서요....). 그래서 시험삼아 StringGrid에 강저적으로 입력값을 넣고 짜보았거든요... 근데.. 컴파일했더니 에러는 안나는데 데이타가 찍히지 않거든요 .. 그래서 코드를 올릴께요... 책을 보니 DB연동한 예제만 나와있어서 어떤밴드를 써야한는지 잘 모르겠거든요... 거 참....
급한 부분이래서 ..
메인부분 :
unit uPrint;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Yislabel, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
YISLabel1: TYISLabel;
Button1: TButton;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses uPrint1, uPrint2;
{$R *.DFM}
procedure TForm1.FormShow(Sender: TObject);
begin
begin
StringGrid1.Cells[0,0] := 'Name';
StringGrid1.Cells[1,0] := 'sex';
StringGrid1.Cells[2,0] := 'hobby';
StringGrid1.Cells[3,0] := 'pay';
StringGrid1.Cells[4,0] := 'telnum';
StringGrid1.Cells[5,0] := 'address';
StringGrid1.Cells[0,1] := 'Name';
StringGrid1.Cells[1,1] := 'sex';
StringGrid1.Cells[2,1] := 'hobby';
StringGrid1.Cells[3,1] := 'pay';
StringGrid1.Cells[4,1] := 'telnum';
StringGrid1.Cells[5,1] := 'address';
StringGrid1.Cells[0,2] := 'Name';
StringGrid1.Cells[1,2] := 'sex';
StringGrid1.Cells[2,2] := 'hobby';
StringGrid1.Cells[3,2] := 'pay';
StringGrid1.Cells[4,2] := 'telnum';
StringGrid1.Cells[5,2] := 'address';
StringGrid1.Cells[0,3] := 'Name';
StringGrid1.Cells[1,3] := 'sex';
StringGrid1.Cells[2,3] := 'hobby';
StringGrid1.Cells[3,3] := 'pay';
StringGrid1.Cells[4,3] := 'telnum';
StringGrid1.Cells[5,3] := 'address';
StringGrid1.Cells[0,4] := 'Name';
StringGrid1.Cells[1,4] := 'sex';
StringGrid1.Cells[2,4] := 'hobby';
StringGrid1.Cells[3,4] := 'pay';
StringGrid1.Cells[4,4] := 'telnum';
StringGrid1.Cells[5,4] := 'address';
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.QuickRep1.preview;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
Form3.QuickRep1.preview;
end;
end.
프린트 부분 :
unit uPrint1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, QuickRpt,uPrint, Qrctrls, StdCtrls;
type
TForm2 = class(TForm)
QuickRep1: TQuickRep;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
procedure QuickRep1NeedData(Sender : TObject; Var MoreData : Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
CurItem : Integer;
implementation
{$R *.DFM}
procedure TForm2.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
CurItem := 1;
end;
procedure TForm2.QuickRep1NeedData(Sender : TObject; Var MoreData : Boolean);
begin
if CurItem < Form1.StringGrid1.Rowcount then
begin
QRLabel1.Caption := Form1.StringGrid1.Cells[0,CurItem];
QRLabel2.Caption := Form1.StringGrid1.Cells[1,CurItem];
QRLabel3.Caption := Form1.StringGrid1.Cells[2,CurItem];
QRLabel4.Caption := Form1.StringGrid1.Cells[3,CurItem];
QRLabel5.Caption := Form1.StringGrid1.Cells[4,CurItem];
QRLabel6.Caption := Form1.StringGrid1.Cells[5,CurItem];
Inc(CurItem); // CurItem을 증가시키면서 현재까지 출력된 개수를 가리키게 한다
MoreData := CurItem < Form1.StringGrid1.RowCount;
end;
end;
end.
빨리 좀 부탁합니다......
> StrinfGrid의 내용을 인쇄코드를 짜려고 합니다(퀵레포트 이용해서요....). 그래서 시험삼아 StringGrid에 강저적으로 입력값을 넣고 짜보았거든요... 근데.. 컴파일했더니 에러는 안나는데 데이타가 찍히지 않거든요 .. 그래서 코드를 올릴께요... 책을 보니 DB연동한 예제만 나와있어서 어떤밴드를 써야한는지 잘 모르겠거든요... 거 참....
> 급한 부분이래서 ..
>
> 메인부분 :
>
> unit uPrint;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
> StdCtrls, Yislabel, Grids;
>
> type
> TForm1 = class(TForm)
> StringGrid1: TStringGrid;
> YISLabel1: TYISLabel;
> Button1: TButton;
>
> procedure FormShow(Sender: TObject);
> procedure Button1Click(Sender: TObject);
> procedure FormClick(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> uses uPrint1, uPrint2;
>
> {$R *.DFM}
>
>
>
> procedure TForm1.FormShow(Sender: TObject);
> begin
> begin
> StringGrid1.Cells[0,0] := 'Name';
> StringGrid1.Cells[1,0] := 'sex';
> StringGrid1.Cells[2,0] := 'hobby';
> StringGrid1.Cells[3,0] := 'pay';
> StringGrid1.Cells[4,0] := 'telnum';
> StringGrid1.Cells[5,0] := 'address';
>
> StringGrid1.Cells[0,1] := 'Name';
> StringGrid1.Cells[1,1] := 'sex';
> StringGrid1.Cells[2,1] := 'hobby';
> StringGrid1.Cells[3,1] := 'pay';
> StringGrid1.Cells[4,1] := 'telnum';
> StringGrid1.Cells[5,1] := 'address';
>
> StringGrid1.Cells[0,2] := 'Name';
> StringGrid1.Cells[1,2] := 'sex';
> StringGrid1.Cells[2,2] := 'hobby';
> StringGrid1.Cells[3,2] := 'pay';
> StringGrid1.Cells[4,2] := 'telnum';
> StringGrid1.Cells[5,2] := 'address';
>
> StringGrid1.Cells[0,3] := 'Name';
> StringGrid1.Cells[1,3] := 'sex';
> StringGrid1.Cells[2,3] := 'hobby';
> StringGrid1.Cells[3,3] := 'pay';
> StringGrid1.Cells[4,3] := 'telnum';
> StringGrid1.Cells[5,3] := 'address';
>
> StringGrid1.Cells[0,4] := 'Name';
> StringGrid1.Cells[1,4] := 'sex';
> StringGrid1.Cells[2,4] := 'hobby';
> StringGrid1.Cells[3,4] := 'pay';
> StringGrid1.Cells[4,4] := 'telnum';
> StringGrid1.Cells[5,4] := 'address';
> end;
> end;
>
> procedure TForm1.Button1Click(Sender: TObject);
> begin
> Form2.QuickRep1.preview;
> end;
>
> procedure TForm1.FormClick(Sender: TObject);
> begin
> Form3.QuickRep1.preview;
> end;
>
> end.
>
> 프린트 부분 :
>
> unit uPrint1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
> ExtCtrls, QuickRpt,uPrint, Qrctrls, StdCtrls;
>
> type
> TForm2 = class(TForm)
> QuickRep1: TQuickRep;
> QRLabel1: TQRLabel;
> QRLabel2: TQRLabel;
> QRLabel3: TQRLabel;
> QRLabel4: TQRLabel;
> QRLabel5: TQRLabel;
> QRLabel6: TQRLabel;
> procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
> var PrintReport: Boolean);
> procedure QuickRep1NeedData(Sender : TObject; Var MoreData : Boolean);
> private
> { Private declarations }
> public
> { Public declarations }
>
>
> end;
>
> var
> Form2: TForm2;
> CurItem : Integer;
> implementation
>
> {$R *.DFM}
>
> procedure TForm2.QuickRep1BeforePrint(Sender: TCustomQuickRep;
> var PrintReport: Boolean);
> begin
> CurItem := 1;
> end;
>
>
> procedure TForm2.QuickRep1NeedData(Sender : TObject; Var MoreData : Boolean);
> begin
> if CurItem < Form1.StringGrid1.Rowcount then
> begin
> QRLabel1.Caption := Form1.StringGrid1.Cells[0,CurItem];
> QRLabel2.Caption := Form1.StringGrid1.Cells[1,CurItem];
> QRLabel3.Caption := Form1.StringGrid1.Cells[2,CurItem];
> QRLabel4.Caption := Form1.StringGrid1.Cells[3,CurItem];
> QRLabel5.Caption := Form1.StringGrid1.Cells[4,CurItem];
> QRLabel6.Caption := Form1.StringGrid1.Cells[5,CurItem];
> Inc(CurItem); // CurItem을 증가시키면서 현재까지 출력된 개수를 가리키게 한다
> MoreData := CurItem < Form1.StringGrid1.RowCount;
> end;
> end;
>
>
>
> end.
>
> 빨리 좀 부탁합니다......
TQRStringBand를 사용해 보세요
Items에 StringGrid의 Row 만큼 넣어 주시구요.