Nested Group

Hellow,

How Can I Set NestedGorup Programmatic
when my code is this :
LastGroupHeader.NestedGroup = new FastReport.GroupHeaderBand();
I encounter this exception :
Object of type GroupHeaderBand cannot contain objects of type GroupHeaderBand


Comments

  • edited 1:24AM
    Hello,

    You have to disconnect the main group's Data band first, before adding a nested group:
          // create the main group
          GroupHeaderBand mainGroup = new GroupHeaderBand();
          mainGroup.Height = Units.Millimeters * 10;
          mainGroup.Name = "MainGroup";
          mainGroup.Condition = "[Orders.CustomerName]";
          // add a group to the page
          page.Bands.Add(mainGroup);
    
          // create a data band
          DataBand dataBand = new DataBand();
          dataBand.Height = Units.Millimeters * 10;
          dataBand.Name = "GroupData";
          dataBand.DataSource = report.GetDataSource("Orders");
          // connect the databand to the nested group
          mainGroup.Data = dataBand;
    
    
          // now create the nested group
          GroupHeaderBand nestedGroup = new GroupHeaderBand();
          nestedGroup.Height = Units.Millimeters * 10;
          nestedGroup.Name = "NestedGroup";
          nestedGroup.Condition = "[Orders.OrderDate]";
          
          // add it to the main group. Disconnect main group data band first!
          nestedGroup.Data = dataBand;
          mainGroup.NestedGroup = nestedGroup;
    
  • edited 1:24AM
    thanks,disconnect data was the gist

Leave a Comment