do caculation on every row in databand

hi 

this my code in fastreport.net to do some calculation for every row in databand on each page

of PreparedPages but it only works for the first row.

it would be a great help and very kind of you to rewrite my code.


public void CalculateSaalScore2()

  {

   double calc = 0;

   FastReport.Preview.PreparedPages pages = Report.PreparedPages;

   ReportPage P = pages.GetPage(Report.Preview.PageNo - 1);

   var dataBand = Report.FindObject("Data3") as DataBand;

   var dataSource = dataBand.DataSource; 

   for (int i = 0; i < dataSource.RowCount; i++) 

   { 

     TableCell objM1=(TableCell)dataSource.FindObject("CellM1");

     TableCell objP1=(TableCell)P.FindObject("CellP1");

     TableCell objM2=(TableCell)P.FindObject("CellM2");

     TableCell objP2=(TableCell)P.FindObject("CellP2");

     TableCell objSaalScore=(TableCell)P.FindObject("CellSaalScore");

  

     calc= (Convert.ToDouble(objM1.Text)+Convert.ToDouble(objM2.Text)+ (Convert.ToDouble(objP1.Text)*2)+ (Convert.ToDouble(objP2.Text)*4) )/8 ;

     objSaalScore.Text=calc.ToString();

    

     if(Report.Preview != null)

     {


      Report.PreparedPages.ModifyPage(Report.Preview.PageNo - 1, objM1.Page as ReportPage);

      //Refresh preview

      Report.Preview.Refresh();

     }

      

  }

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.