Format textbox

4 posts, 0 answers
  1. rob mays
    rob mays avatar
    58 posts
    Member since:
    Jun 2007

    Posted 14 Jun 2007 Link to this post

    I would like to know how and where I set the format for a textbox to display the date in 'dd/mm/yyyy' my report is displayed in a reportviewer on a web page. What will the TextBox1.Format = ""
    string look like?

    OK found it
  2. Hrisi
    Admin
    Hrisi avatar
    221 posts

    Posted 14 Jun 2007 Link to this post

    Hello rob mays,

    You can set Format property of the TextBox in тхе Property Grid to "{0:dd\/MM\/yyyy}"

     
    Kind regards,
    Hrisi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft banner
  4. Jason McIntyre
    Jason McIntyre avatar
    26 posts
    Member since:
    Mar 2007

    Posted 29 Sep 2007 Link to this post

    Is it possible to format a date inside a textbox - as I append some text to the line ?

    ie  =Now().ToString('{0:dd\/MM\/yyyy}') + " - Quote Number: " + Fields.quotenumber
  5. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 01 Oct 2007 Link to this post

    Hello Jason McIntyre,

    This is a valid expression and you can use it for your text boxes. With the Q2 2007 release there is a know issue with calling overloaded methods which is the case with DateTime.ToString(). This issue will be fixed in the upcoming service pack, due in two weeks.

    Luckily, there are several workarounds - you can handle the TextBox's ItemDataBinding/Bound event or you can use a user function. We strongly encourage you to try the 2nd approach as we consider it to be superior.

    User defined functions are new to Telerik Reporting Q2 2007 and are public static (Shared in Visual Basic.NET)  non-void (that return value) methods defined in your report classes. They can be used in any expression (item value, filters, grouping, sorting, conditional formatting) in the report they belong to. Once defined (and the project is compiled) at design time they appear in the Expression Builder which makes their use easier. Here is a sample function (in C#) that you can use to format the value of your text box:

    class Report1 : Telerik.Reporting.Report
    {
        ...
       
        public static string FormatQuoteNumber(int quoteNumber)
        {
            return string.Format("{0:dd/MM/yyyy} - Quote Number: {1}"
                , DateTime.Now
                , quoteNumber);
        }
        ...
    }


    Then for the textbox's value expression you can use this simpler expression:

    =FormatQuoteNumber(Fields.quotenumber)

    As you may already noticed the user defined functions extends the built-in functionality beyond the limits of its scripting engine and let you create advanced reports easier.

     
    Kind regards,
    Svetoslav
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top