Results 1 to 2 of 2

Thread: [RESOLVED] Converting VB6 CrystalReport SectionFormat to C#

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,698

    Resolved [RESOLVED] Converting VB6 CrystalReport SectionFormat to C#

    I am in the process of converting a VB6 application to C#. One of the things that the legacy application does to a particular Crystal Report is the following:
    Code:
    With frmResources2.Report1
        .ReportFileName = "PO.rpt"
        .SelectionFormula = "..."
        .SectionFormat(0) = "GF1;F;F;F;X;X;X;X;X;X"
        .SectionFormat(1) = "TITLE;F;F;F;X;X;X;X;X;X"
    
        .Action = 1 ' Print
    End With
    I have no idea what the section format is doing nor do I know how to convert it.

    In C# SectionFormat is not a property on the ReportDocument class. It appears as if it exists as a ReadOnly property when I do this:
    Code:
    report.ReportDefinition.Sections[counter].SectionFormat;
    But there aren't any properties on the SectionFormat class that let me specify the format like it is being done in VB6.
    Last edited by dday9; Dec 24th, 2020 at 02:40 PM.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  2. #2

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,698

    Re: Converting VB6 CrystalReport SectionFormat to C#

    In my case, I had to correlate the GF1 and TITLE values to their respective sections in the report's .cs file and then set those section's EnableSuppress to true:
    Code:
    // filter["EnableSuppress"] = [0, 6]
    foreach (int section in filter["EnableSuppress"])
    {
        var sectionFormat = report.ReportDefinition.Sections[section]?.SectionFormat;
        if (sectionFormat != null)
        {
            sectionFormat.EnableSuppress = true;
        }
    }
    filter.Remove("EnableSuppress");
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width