Search Results for

    Show / Hide Table of Contents

    Example 3. Printing the name of the month

    In the previous example, there were numbers of months printed in a matrix. This occurred, because the Month data column contains the number of the month, not its name. In order to print the name of the month, do the following:

    • choose a cell where the number of the month is printed. In our case it is a cell with a name "Cell8";

    • in the "Property" window press the button and double click BeforePrint event;

    • FastReport will add an empty event handler in the report script. Write the following code:

    private void Cell8_BeforePrint(object sender, EventArgs e)
    {
      string[] month Names = newstring[] {
        "January", "February", "March", "April", 
        "May", "June", "July", "August", 
        "September", "October", "November", "December" };
      // Cell8 is a cell that prints the month number.
      // Cell8.Value is a value printed in the cell (i.e. the month number).
      // This value is of System.Object type, so we need to cast it to int
      Cell8.Text = monthNames[(int)Cell8.Value - 1];
    }
    

    When you run the report, you will have the following result:

    Back to top © 1998-2025 Copyright Fast Reports Inc.