Highlighted
Super Contributor.
Super Contributor.
2260 views

COBCH1623 error when attach method

This line of code gives the error "COBCH1623: Anonymous method or method group cannot be cast to type DevExpress.XtraPrinting.CreateAreaEventHander.":

ATTACH METHOD link__CreateReportHeaderArea to link::CreateReportHeaderArea

This is the C# code that I'm converting to Visual COBOL:

      private void btnPrint_Click(object sender, EventArgs e)
        {
            IPrintable component = gridControl1;
            PrintableComponentLinkBase link = new PrintableComponentLinkBase()
            {
                PrintingSystemBase = new PrintingSystemBase(),
                Component = component,
            };
            link.CreateReportHeaderArea += link_CreateReportHeaderArea;

        }
        private void link_CreateReportHeaderArea(object sender,
        CreateAreaEventArgs e)
        {
            string reportHeader = "Categories Report";
            e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Center);
            e.Graph.Font = new Font("Tahoma", 14, FontStyle.Bold);
            RectangleF rec = new RectangleF(0, 0, e.Graph.ClientPageSize.Width, 50);
            e.Graph.DrawString(reportHeader, Color.Black, rec, BorderSide.None);
        }

I don't get the error in C#, just COBOL, and I am not able to subscribe to the CreateReportHeaderArea event.  Any ideas on how to get this working?

Phil Levin

Tags (1)
0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: COBCH1623 error when attach method

Hi Phil,

What does the method signature for link__CreateReportHeaderArea  look like in COBOL?

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: COBCH1623 error when attach method

      method-id link_CreateReportHeaderArea final private.

      procedure division using by value sender as object e as type CreateAreaEventArgs.

          goback.

      end method.

Intellisense shows me the error even if I have this method commented out.

Phil Levin

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: COBCH1623 error when attach method

Is it just a typo that you have two consecutive underscores in the name in the ATTACH statement or is that the actual problem?

"link__CreateReportHeaderArea"

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: COBCH1623 error when attach method

Here is the COBOL code I wrote for subscribing to the event:

   $set ilusing"DevExpress.XtraPrinting"

   $set ilusing"DevExpress.XtraPrinting.Links"

   $set ilusing"DevExpress.XtraPrintingLinks"

                         .

                         .

                         .

    method-id btnPrint_Click final private.

      local-storage section.

        01  link                                       type PrintableComponentLinkBase.

        01  PrintingSystemBase        type PrintingSystemBase.

        01  component                         type IPrintable.

      procedure division using by value sender as object e as type System.EventArgs.

          set component to gridControl1

          set link to new type PrintableComponentLinkBase.

          set PrintingSystemBase to new type PrintingSystemBase.

          set Component to component.

          ATTACH METHOD link__CreateReportHeaderArea to link::CreateReportHeaderArea

      end method.

Phil Levin

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: COBCH1623 error when attach method

I did have an extra underscore in my code but after removing it I still get the COBCH1623 error.

Phil Levin

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: COBCH1623 error when attach method

Please open up a support incident with Customer Care for this as we will most likely require a cutdown example.

Thanks.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.