Hola ido,
Debería funcionar. Utilizo esto para obtener la colección, por lo que la adición está comentada pero debería funcionar para ti:
{
btnReportObjects.Text = "";
flcnt = 0;
foreach (CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject reportObject in rptClientDoc.ReportDefController.ReportObjectController.GetAllReportObjects())
{
var reportSection = rptClientDoc.ReportDefController.ReportDefinition.FindSectionByName(reportObject.SectionName);
for (int index = 0;
index < reportSection.Format.ConditionFormulas.Count;
++index)
{
var formula = reportSection.Format.ConditionFormulas[(CrystalDecisions.ReportAppServer.ReportDefModel.CrSectionAreaFormatConditionFormulaTypeEnum)index];
var NewFormula = reportSection.Format.ConditionFormulas[(CrystalDecisions.ReportAppServer.ReportDefModel.CrSectionAreaFormatConditionFormulaTypeEnum)index];
try
{
if (formula.Text != null)
{
textBox1 = "Fórmula de condición: " + formula.Text.ToString() + "\n";
textBox1 += "Sección " + reportSection.Name + "\n";
}
}
catch (Exception ex)
{
btnReportObjects.Text += "\nExcepción: " + ex.ToString();
}
btnReportObjects.Text += textBox1;
btnReportObjects.AppendText("\n");
++flcnt;
btnCount.Text = flcnt.ToString();
//// Verifica la fórmula agregándola al informe para verificar la sintaxis
//CrystalDecisions.ReportAppServer.ObjectFactory.ObjectFactory objFactory = new CrystalDecisions.ReportAppServer.ObjectFactory.ObjectFactory();
//CrystalDecisions.ReportAppServer.DataDefModel.FormulaField Formula = (CrystalDecisions.ReportAppServer.DataDefModel.FormulaField)objFactory.CreateObject("CrystalReports.FormulaField");
//Formula.Type = CrystalDecisions.ReportAppServer.DataDefModel.CrFieldValueTypeEnum.crFieldValueTypeStringField;
//Formula.Syntax = CrystalDecisions.ReportAppServer.DataDefModel.CrFormulaSyntaxEnum.crFormulaSyntaxCrystal;
//Formula.Text = @"whilereadingrecords; ""A"""; // "hello Ludek = 1"; // resultField.Text; // "n=3"; {Customer.Customer Credit ID} + 1 @"whilereadingrecords; ""A"""
//Formula.Name = "TestDon"; // "TestDon"; // resultField.Name; //"testformula";
//String FormulaMessage = rptClientDoc.DataDefController.FormulaFieldController.Check(Formula);
//if (FormulaMessage == null)
//{
// // luego agrega la fórmula condicional si está correcta
// string newFormulaText = "'Funcionó' = 'Funcionó'";
// // Clona un formato de sección y usa ReportSectionController.SetPropety para modificar las ConditionFormulas
// CrystalDecisions.ReportAppServer.ReportDefModel.SectionFormat newFormat = reportSection.Format.Clone(true);
// newFormat.ConditionFormulas[(CrystalDecisions.ReportAppServer.ReportDefModel.CrSectionAreaFormatConditionFormulaTypeEnum)index].Text = newFormulaText;
// rptClientDoc.ReportDefController.ReportSectionController.SetProperty(reportSection, CrReportSectionPropertyEnum.crReportSectionPropertyFormat, newFormat);
//}
//else
// btnReportObjects.Text += "Hay errores en la fórmula: " + FormulaMessage.ToString() + "\n";
}
}
}
Don