I have a class thats receive all crystal report req to open the form of the report(a switch and a lot of cases).
and i need to copy and paste every time this code
if (sender.GetType() == typeof(CheckBox))
{
foreach (CheckBox elemento in flowLayoutPanel1.Controls.OfType<CheckBox>())
{
if (elemento.Checked)
{
foreach (string elemento2 in ListaTodos)
{
string Name = elemento.Tag.ToString();
if (Name.Substring(Name.Length - 1, 1) == elemento2.Substring(elemento2.Length - 1, 1))
{
crParceiro.ReportDefinition.ReportObjects[Name].ObjectFormat.EnableSuppress = false;
crParceiro.ReportDefinition.ReportObjects[elemento2].ObjectFormat.EnableSuppress = false;
}
}
}
else
{
foreach (string elemento2 in ListaTodos)
{
string Name = elemento.Tag.ToString();
if (Name.Substring(Name.Length - 1, 1) == elemento2.Substring(elemento2.Length - 1, 1))
{
crParceiro.ReportDefinition.ReportObjects[Name].ObjectFormat.EnableSuppress = true;
crParceiro.ReportDefinition.ReportObjects[elemento2].ObjectFormat.EnableSuppress = true;
}
}
}
}
}
Problem: i created a function and triend to paste this part of code there... and i passed the crParceiro.ReportDefinition, and also crParceiro.ReportDefinition.ReportsObject but it doesnt have the set property and i cant set it out and return on REF our OUT...
I tried to Return the value and Linq Expressions(it says..."object doesnt have set property") no success **Reference of Linq Exp and Return Value: **Link here
A good example of the problem are:
ReportDefinition teste = new ReportDefinition();
teste.ReportObjects = null;
//Error: Property or idexer ...cannot be assigned to -- its read only.
what can i do? im very lost..