GridViewDateTimeColumn formatString

4 posts, 0 answers
  1. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 16 Apr 2009 Link to this post


    Maybe a stupid question, but I was wondering if there is an overview of the different formatstrings you can use for the DateTime Column?

    I want to make a static function where I just need to call the right formatString, instead of every time searching the "net" for the right syntacs and add it.

  2. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 17 Apr 2009 Link to this post

    Hello Gerbrand,

    These are some samples of formatting DateTime column in RadGridView:

    GridViewDateTimeColumn column = (GridViewDateTimeColumn)this.radGridView1.Columns["Date"];  
    column.DataTextFormatString = "{}";  //hour.minutes.seconds 
    column.DataTextFormatString = "{0:dd.MM.yy}";  //day.month.year 
    column.DataTextFormatString = "{}";      //hour.minutes 
    column.DataTextFormatString = "{0:dd.MMMM.yy}";  //day.long month name.year 
    column.DataTextFormatString = "{0:dd-MM-yy}";  //day-month-year 

    You can find more information for DateTime formatting in MSDN.

    Julian Benkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. tuonglam
    tuonglam avatar
    3 posts
    Member since:
    Sep 2011

    Posted 09 Sep 2011 Link to this post

    I'm using like you say but i have a error.I'm using in Formload

    'Telerik.WinControls.UI.GridViewDateTimeColumn' does not contain a definition for 'DataTextFormatString' and no extension method 'DataTextFormatString' accepting a first argument of type 'Telerik.WinControls.UI.GridViewDateTimeColumn' could be found (are you missing a using directive or an assembly reference?)

    My code:

    GridViewDateTimeColumn column = (GridViewDateTimeColumn)this.radGridView1.Columns["Date"];
     column.DataTextFormatString = "{dd-MM-yy}";  //day-month-year

    thank you very much!
  4. Nikolay
    Nikolay avatar
    1805 posts

    Posted 14 Sep 2011 Link to this post

    Hi Tuonglam,

    The code snippet provided by my colleague Julian concerned a version of RadControls for WinForms issued during 2009. If you are using one of the latest versions, you have to use the FormatString property as shown below:

    GridViewDateTimeColumn column = (GridViewDateTimeColumn)this.radGridView1.Columns["Date"];
    column.FormatString = "{}"//hour.minutes.seconds
    column.FormatString = "{0:dd.MM.yy}"//day.month.year
    column.FormatString = "{}";      //hour.minutes
    column.FormatString = "{0:dd.MMMM.yy}"//day.long month name.year
    column.FormatString = "{0:dd-MM-yy}"//day-month-year

    I hope this helps.

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top