Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo

Date format in datagrid (Friday, September 03, 2004)






Found the following interesting discussion in the Newsgroups:

Date format in datagrid
by:Niclas Lindblom

Hi,

I have a bound column in a datagrid. The value in the database is using the SQL datetime format which gives both date and time. How do I configure the datagrid cell to only display the date in the format DD/MM/YYYY ? I have tried

colDateCompleted.DataFormatString = "{0:d}"

but this still displays the whole date including the time.

Any help appreciated

Regards

Niclas


 Reply:
by:Ken Tucker [MVP]

 Hi,

You have to add a tablestyle to your grid.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchformattingwindowsformsdatagridvisualbasicprimer.asp

Ken



Posted by Xander Zelders





2 Comments:

Blogger Magician said...

Use {0:dd/MM/yyyy}

Best Regards

6:26 AM  
Anonymous Anonymous said...

Use this "{0:MM/dd/yyyy}" as well as HtmlEncode="false" then you will be able to see the formatted string.

11:36 AM  

Post a Comment

<< Home

 
Previous Posts
    - Catching An Error
    - Conversion issue with option strict
    - How to activate the childform, arraylist, childmdi...
    - How to activate the childform, arraylist, childmdi...
    - Basic data processing with .net
    - Multiuser Problem in .net
    - MD5 checksum of Visual Studio 2k5 preview
    - scrollbar.scroll event occuring twice
    - Help with Graphics primitives
    - Setting button image with vb.net

Archives
    - 08/01/2004 - 08/08/2004
    - 08/08/2004 - 08/15/2004
    - 08/15/2004 - 08/22/2004
    - 08/22/2004 - 08/29/2004
    - 08/29/2004 - 09/05/2004
    - 09/05/2004 - 09/12/2004
    - 09/12/2004 - 09/19/2004
    - 09/19/2004 - 09/26/2004
    - 09/26/2004 - 10/03/2004
    - 10/03/2004 - 10/10/2004
    - 01/02/2005 - 01/09/2005
    - 01/09/2005 - 01/16/2005
    - 01/30/2005 - 02/06/2005
    - 01/01/2006 - 01/08/2006


Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland