Print Page | Close Window

Condition Formula change with C#.NET

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=16983
Printed Date: 03 May 2025 at 8:19pm


Topic: Condition Formula change with C#.NET
Posted By: Silvan
Subject: Condition Formula change with C#.NET
Date Posted: 09 Jul 2012 at 1:05am
Hi
I have made a Methode "ReplaceFormelFelder" (below) which can search and replace a string in the FormulaFields. Now I would do the same for the condition formulas. How can I do that?
There is a picture from a condition formula (supress formula):
http://imageshack.us/photo/my-images/812/crprob.png/ - http://imageshack.us/photo/my-images/812/crprob.png/
 

        public static int ReplaceFormelFelder(ReportDocument rpt, string oldValue, string newValue)
        {
            int iCounter = 0, index = 0;
            bool replace = false;
            string text = string.Empty;
 
            foreach (FormulaFieldDefinition item in rpt.DataDefinition.FormulaFields)
            {
                text = item.Text;
                if (text != null)
                {
                    index = text.IndexOf(oldValue);
 
                    while (index != -1)
                    {
                        iCounter++;
                        replace = true;
 
                        if (text.Length > index + 1)
                            index = text.IndexOf(oldValue,index + 1);
                        else
                            index = -1;
                    }
 
                    if (replace)
                    {
                        item.Text = text.Replace(oldValue,newValue);
                        replace = false;
                    }
                }
            }
 
            return iCounter;
        }




Replies:
Posted By: hilfy
Date Posted: 10 Jul 2012 at 7:25am
For the report selection formula, look at the ReportDocument.DataDefinition.RecordSelectionFormula property.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window