Have a .Text Expression in C# Code
Hello,
because we get updated Report we like to have all settings in Report Source Code at one place.
we have a Text Field with a expression like .Text ="[fieldname]"
i made a function to replace this text it looks like [ChangeMe([fieldname])] that works well in report designer UI.
now i need the same within C# but it seems the function is not found at report preview .
having MyTextField.Text = "[ChangeMe([fieldname])]" run into error.
please help :)
This discussion has been closed.

Comments
This is an older post, but I think you should be someting like this:
MyTextField.Text = ChangeMe((string)Report.GetColumValue("fieldname"));So I would think "fieldname" will have to become "datasource.fieldname". ChangeMe should then also be a C# function that is called with a string argument and returns another string?
thanks, we will test some day.
Hello!
The thing is that [...] this is a FastReport .NET expression; it is compiled by the report script during the `Prepare()` method. Assigning `Text` from C# does not add the function to the script: `ChangeMe` must either be in the script of the loaded .frx file or registered as a static report function.
Calculate the value in C# and substitute the finished string — then FastReport won’t attempt to compile the expression:
var column = (string)report.GetColumnValue(‘Items.fieldname’);myTextField.Text = ChangeMe(column); // without square bracketsAlternatively, register it afterwards as shown in our article: https://www.fast-report.com/blogs/custom-libraries-functions-designer