Page 1 of 1

Doubt about coding

Posted: Thu Apr 07, 2011 4:12 pm
by Nathália Maria Marini Karna
Hi,

I’m facing some troubles with the coding in the report designer.
I’ve read the tutorials that are in the site, but it wasn’t enough to solve my doubt.

Question 1:
How could I change the value of “variable to change”? As the picture below.
Image


I want the “Variable to change” to receive the sum of the column “consumo”. How can I do this by the code?

I’ve already tried to do it using like “Text2.Text = “test” “, but even this don’t work.

Question 2:
Where do I put the “code”? Should I create a class to it, or I just make the methods anywhere after the “Designer generated code”?

Doubt about coding

Posted: Fri Apr 08, 2011 5:53 am
by Alex K.
Hello,
Nathália wrote:Question 1:
How could I change the value of “variable to change”? As the picture below.
Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?
Nathália wrote:Question 2:
Where do I put the “code”? Should I create a class to it, or I just make the methods anywhere after the “Designer generated code”?
If you want to add a code to the events of the elements, you can write your code on the Events tab of the property panel. If you want to add your own methods, then it is necessary to add on the Code tab before or after the region "# region StiReport Designer generated code - do not modify".

Thank you.

Doubt about coding

Posted: Fri Apr 08, 2011 6:35 am
by Nathália Maria Marini Karna
What I meant is that where is writen "variable to change" exist a Text box that will receive a value, this value will be the sum of all the "Consumo" column.
In a very simple way, I need to know for example how the variable receive a value in the code, like:
In c# is really simple to do this: variable.Text = variable2.ToString();



Doubt about coding

Posted: Fri Apr 08, 2011 11:39 am
by Jan
Hello,
Nathália wrote:What I meant is that where is writen "variable to change" exist a Text box that will receive a value, this value will be the sum of all the "Consumo" column.
In a very simple way, I need to know for example how the variable receive a value in the code, like:
In c# is really simple to do this: variable.Text = variable2.ToString();
If I correct understand you can use GetValueEvent of text component from Events Tab. You can use code similar to:

Code: Select all

e.Value = "New value";
e.Value already contain final version of text. Additional example:

Code: Select all

e.Value = Totals.Sum(MyDataSource, MyExpression).ToString();
Thank you.

Doubt about coding

Posted: Fri Apr 08, 2011 3:01 pm
by Nathália Maria Marini Karna
thank you for the help!!

But what i really want is to atribute some value to one variable that is not the one that is executing the event.
For example:

if(Text1.Text.Equals("x")){
e.Value = Totals.Sum(Table7,[Consumo Sucata por Maquina].Sucata).ToString();
}

how should I use "Text1.Text"??

Thank you again

Doubt about coding

Posted: Mon Apr 11, 2011 3:24 am
by Alex K.
Hello,

You can use the following code:

Code: Select all

if(e.Value.Equals("x"))
{
     e.Value = Totals.Sum(Table7,[Consumo Sucata por Maquina].Sucata).ToString();
}
Thank you.