Cross Tab Object problems

MrWDMrWD Calgary AB, Canada
edited 10:48PM in FastReport 4.0
I looked at the SringGrid example and used it as a template. I made a frxReport and created a Master Data band and the placed a frxCrossView object in it. It assigned 'Cross1' as the object name. I then created a procedure named rptAlertPopulate which is supposed to add the values inti Cross1. Try as I may I cannot get the data to print. Here is the code. Hoping someone can put me in the right direction. BTW I did try to use the rptAlertBeforePrint event approach and still no luck.

Thx



unit frmMainU;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, JvComponentBase, JvMail, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient,
IdPOP3, IdSMTPBase, IdSMTP, LMDCustomScrollBox, LMDListBox, LMDCustomButton,
LMDButton, IdMessage, LMDControl, LMDCustomControl, LMDCustomPanel,IDAttachmentFile,
LMDCustomBevelPanel, LMDCustomStatusBar, LMDStatusBar,IdText,IdGlobal,IdSync,
ComCtrls, Buttons, ExtCtrls, frxClass, frxPrinter, frxCross;

type
TfrmMain = class(TForm)
SalesOrdersPOP3: TIdPOP3;
IdSMTP1: TIdSMTP;
mess: TIdMessage;
list: TListView;
Timer1: TTimer;
BitBtn1: TBitBtn;
Label1: TLabel;
rptAlert: TfrxReport;
frxCrossObject1: TfrxCrossObject;
procedure Timer1Timer(Sender: TObject);
procedure rptAlertPopulate;
private
{ Private declarations }
public
{ Public declarations }
Msgcount:Integer;
li:TListItem;
end;

var
frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure TfrmMain.rptAlertPopulate;
var
Cross: TfrxCrossView;
vRow: Integer;
begin
Cross := TfrxCrossView(rptAlert.FindObject('Cross1'));
for vRow := 0 to list.Items.Count - 1 do
begin
Cross.AddValue([vRow + 1],,[list.Items[vRow].Caption]);
Cross.AddValue([vRow + 1],,[list.Items[vRow].SubItems[0]]);
Cross.AddValue([vRow + 1],,[list.Items[vRow].SubItems[1]]);
end;
end;

procedure TfrmMain.Timer1Timer(Sender: TObject);
var
intindex:Integer;
begin
try
if not SalesOrdersPOP3.Connected then
SalesOrdersPOP3.Connect;
except
showmessage('Could not connect to pop server, please check your connection details');
exit;
end;
msgcount:=SalesOrdersPOP3.CheckMessages;
if msgcount > 0 then
begin
SalesOrdersPOP3.RetrieveHeader(msgcount,mess);
list.Items.Clear;
for intindex:= 1 to msgcount do
begin
Application.ProcessMessages;
Mess.Clear;
SalesOrdersPOP3.RetrieveHeader(intIndex, Mess);
li:=list.Items.Add;
li.ImageIndex := 4;
li.Caption:= mess.From.text;
li.SubItems.add(formatdatetime('dd/mm/yyy hh:mm:ss',mess.Date));
li.SubItems.Add(mess.Subject);
end;
rptAlertPopulate;
rptAlert.printoptions.showdialog := false;
rptAlert.PrintOptions.Printer := 'EPSON WorkForce 610 Series';
rptAlert.showreport;
end;
SalesOrdersPOP3.Disconnect;
end;

end.

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 10:48PM
    first before using the find object method you must have the tfrxreport component load the .fr3 file unless you are storing in the dfm.

    change this line
    Cross := TfrxCrossView(rptAlert.FindObject('Cross1'));
    to
    Cross := rptAlert.FindObject('Cross1') as tfrxcrossview; // find and cast to type
    now you can add values using the add value method.
  • MrWDMrWD Calgary AB, Canada
    edited October 2010
    Thank you for your reply. I tried your recommendations. The StoreInDfm property is set to True for the frxReport component. It compiled cleanly but still have nothing printing out. Very perplexing problem. :angry:" border="0" alt="mad.gif" />" alt=">" />
  • gordkgordk St.Catherines On. Canada.
    edited 10:48PM
    did you set the masterdataband rowcount property to 1
  • MrWDMrWD Calgary AB, Canada
    edited 10:48PM
    Thank you Gordk. It was set to 0 so changed it to 1 and still no luck >
  • gordkgordk St.Catherines On. Canada.
    edited 10:48PM
    on checking my notes and testing
    You must use the onbeforeprint event of the tfrxreport component to populate the crossmatrix.
    also make sure that in the report you have set up the crossview using its editor.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.