Hello,
I have problem with variable. If I assign variable value and run report as preview, it works well. But if I run report in design and I show preview there, variable has not its value. Variable has its default value. :dumb: Why doesn't variable have assigned value?
I tested it also in your sample Variables and there is problem too.
private void button1_Click(object sender, System.EventArgs e)
{
stiReport1.Load("..\\..\\Variables.mrt");
stiReport1.Compile();
//Set Variables
stiReport1["Name"] = tbName.Text;
stiReport1["Surname"] = tbSurname.Text;
stiReport1["Email"] = tbEmail.Text;
stiReport1["Address"] = tbAddress.Text;
stiReport1["Sex"] = rbMale.Checked;
stiReport1["BirthDay"] = dtBirthDay.Value;
stiReport1.Design();
}
private void button2_Click(object sender, System.EventArgs e)
{
stiReport1.Load("..\\..\\Variables.mrt");
stiReport1.Compile();
//Set Variables
stiReport1["Name"] = tbName.Text;
stiReport1["Surname"] = tbSurname.Text;
stiReport1["Email"] = tbEmail.Text;
stiReport1["Address"] = tbAddress.Text;
stiReport1["Sex"] = rbMale.Checked;
stiReport1["BirthDay"] = dtBirthDay.Value;
stiReport1.Show();
}
Regards
Beda
Problem with variable
Problem with variable
Hello, Beda.
In the code snippets you have shown assigning of values has been made for the CompiledReport. It is a report template after compilation. There is no ability to Design a compiled report. In the Designer you see the template before compilation which can be stored in xml format in mrt file. After compilation this template becomes "hardcoded". Assigned to the compiled report values is stored nowhere. After calling Design() method CompiledReport property is reset for the report and do not has any values.
The report.CompiledReport property is updated each time when the report.Compile() method is called. When you pressing 'Preview' button, then again Compile() method transforms visual representation of the report into a compiled class. Default values are being taken from that template.
In case you need initial values for variables, it is possible to define their default values in the Dictionary. Right-click on variables and set their initial values or assign them when the Variables are being added for a very first time.
If the report was loaded from template as in your case, then modification of those default values of Variables is also possible as it was done in the following code:
Thank you.
In the code snippets you have shown assigning of values has been made for the CompiledReport. It is a report template after compilation. There is no ability to Design a compiled report. In the Designer you see the template before compilation which can be stored in xml format in mrt file. After compilation this template becomes "hardcoded". Assigned to the compiled report values is stored nowhere. After calling Design() method CompiledReport property is reset for the report and do not has any values.
The report.CompiledReport property is updated each time when the report.Compile() method is called. When you pressing 'Preview' button, then again Compile() method transforms visual representation of the report into a compiled class. Default values are being taken from that template.
In case you need initial values for variables, it is possible to define their default values in the Dictionary. Right-click on variables and set their initial values or assign them when the Variables are being added for a very first time.
If the report was loaded from template as in your case, then modification of those default values of Variables is also possible as it was done in the following code:
Code: Select all
stiReport1.Load("..\\..\\Variables.mrt");
stiReport1.Dictionary.Variables["SurName"].ValueObject = tbSurname.Text;
stiReport1.Design();
Problem with variable
Thank you for your answer and help.
I din't know about this. I will use default value for the design. In this time it's enough to define right design report.
I din't know about this. I will use default value for the design. In this time it's enough to define right design report.
Problem with variable
You are welcome.
Let us know if any help is required.
Thank you.
Let us know if any help is required.
Thank you.