BindValue to a Method

  • We want that whenever the user changes the value for the FromDate column, the value of the ToDate column will automatically recompute to the "End of Month" of the date in the FromDate column
  • Review the second overload of the BindValue method.
    2017 02 26 10H32 48
  • Func<Date> means a method that return Date
  • see Func Power Point Presentation
public class DemoLocalColumns : UIControllerBase
{
    public readonly DateColumn FromDate = new DateColumn("From Date");
    public readonly DateColumn ToDate = new DateColumn("To Date");
    public readonly NumberColumn DaysBetween = new NumberColumn("Days Between","5CN");

    public DemoLocalColumns()
    {
        ToDate.BindValue(GetEndOfMonthOfFromDate);
    }
    public Date GetEndOfMonthOfFromDate()
    {
        return FromDate.EndOfMonth;
    }
  ...
} 
  • Note that we are sending the method GetEndOfMonthOfFromDate as a parameter to the BindValue method without parenthesis
  • Use Debug.WriteLine to demonstrate that the GetEndOfMonthOfFromDate method calculates whenever we change the FromDate column

For a deeper discussion of these topics see Lambda Expressions Generics and BindValue


Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com