Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

OnGetCaptionText for crosstab component

edited June 2003 in General
I added a CrossTabGetCaptionTextEvent event to my application as per a
previous messagein these newsgroups. Does anyone know how to make this even
fire? When I do a crosstab event, I want to translate some column header
names but I can't even get this even to fire. Do I need to assign it to a
report event, or a designer event, etc.?

I assume it's a crosstab event, but I can't determine how to assign it to
the crosstab. Is there even a crosstab object to assign it to? Our report
designer has the crosstab component enabled, but I don't see how to tie this
event to it.

We are using RB 6.03 Pro and Delphi 6.

Thanks in advance,
Vinnie Murdico

Comments

  • edited July 2003
    Hi Vinnie,

    In my testing I have had no trouble getting this event to fire numerous
    times. The following example creates a simple crosstab component and shows
    a message when the GetCaptionText event fires. It fires more than 40 times.
    Once you place a crosstab component on a report you should be able to see
    the events associated with it in the Object Inspector in the Delphi IDE.
    Double click on the GetCaptionText event to gain access to it.

    http://www.digital-metaphors.com/tips/ShowGetCaptionText.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2003
    Ok, I think I see the confusion.

    My problem is that the report is user-created at runtime. I was able to
    open your project and edit the report on the form and then click on the
    crosstab box in the design window and see the GetCaptionText event in the
    Delphi IDE. The problem is that the user drops a crosstab on his new report
    he just created in the designer and there is no Delphi IDE object inspector
    to select the cross tab object and set its event.

    Is there some way to detect at runtime that the user has created a crosstab
    component (dropped on on his report)? If some event was fired when this
    occured, I could get that crosstab object (supposedly ) and set its
    GetCaptionText event to point to my custom procedure.

    Is there any way to set this event to point to my routine when the user is
    creating the report at runtime?

    Thanks,
    Vinnie Murdico


  • edited July 2003
    Hi Vinnie,

    You can use a Report Object loop to detect if certain components are on a
    report. You will probably want to check if the report has any crosstab
    components in the Report.BeforePrint event and then access the event from
    there. Below is an article on report object loops with some sample code
    that should get you in the right direction.

    ----------------------------------------------
    Tech Tip: Loop Thru All Objects in a Report
    ---------------------------------------------

    A ReportBuilder report is composed of a set
    of components. The basic structure is

    Reports.Bands[].Objects[]

    The bands and objects within the report can
    be accessed directly by object name or
    via the Bands and Objects array properties.

    --

    Below is an example of using the Bands and Objects array properties to find
    all CrossTab components in a report.

    uses
    ppClass;


    procedure FindCrossTab(aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;

    begin

    for liBand := 0 to aReport.BandCount-1 do

    for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
    begin
    lObject := aReport.Bands[liBand].Objects[liObject];

    if lObject is TppCrossTab then
    {you create this routine to handle the crosstab component}
    ProcessCrossTabLabels(TppCrossTab(lObject));

    end;

    end;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2003
    Ok, thanks.

    I also see an event for the report called DesignerCreateComponent. Can I
    trap in there to see if the component ClassType is a CrossTab type -- and
    if so, set the GetCaptionText even to point to my function, or will I cause
    problems doing this?

    -- Vinnie
  • edited July 2003
    Hi Vinnie,

    There are actually three ways you could do this.

    - The first would be to use the Object loop as described in the previous
    message.

    - Second you could use the Designer.OnCreateComponent event as you found
    below. Then every time this event fires, you can check the object that is
    getting created and see if it is a TppCrosstab.

    - Third, you could give your users the ability to use RAP. In this case,
    when your users created a crosstab, they could create and edit the event for
    themselves.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.