Totals

Hi,

I create a simply Total, but when I am trying to asign it to TextObject, it doesn't work. This is part of my code:
      Total totalKm = new Total();
      totalKm.Name = "totalKm";
      totalKm.Evaluator = Data1;
      totalKm.Expression = "[dt1.KM]";         
      totalKm.PrintOn = GroupFooter1; 
      totalKm.TotalType = TotalType.Sum; 
      TextObject text = new TextObject();
      text.Text = "[totalKm]";

The error message is "The name "totalKm" doesn't exist in the current content". So I realize, that I have to add it to my Report:
      Report.Dictionary.Totals.Add(totalKm);

But this don't work. I've even try this:
      text.Text = totalKm.Value.ToString();

but I've got Exception "System.NullReferenceException: Object reference not set to an instance of an object", so I think that the value of my Total is null.

What should I do? Is there any way to 'activate' Total? Maybe in the EventHandler --> text.AfterData(or after/before something)?

The main thing is, that all that calculating is in the loop, I don't know how many times it goes and I don't know number of columns. The Totals needs to be dynamically defined and used (columns too), so I need to programm in code, instead of Drag&Drop (and click).

I appreciate for all help, even the little one >

Comments

  • edited 4:16PM
    I've managed to make it work, here is what I've done:

    1. I've created manually couple of Totals in Data --> RMB --> Create Total, but without expression
    2. In code (in loop) I changed the expression dynamically, like this:
    for(int i = 0; i < max; i++)
    (...)
    Report.Dictionary.Totals[0].Expression = "[dt1.Col" + i.ToString() + "]"
    

    Of course columns in my data 'dt1' are named Col1, Col2, depends on number 'max'.

    I've got another question - How do I change Format of TextBox in code? text.Format = ?? What do I have t oassign to it?

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.