Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I change date format from us format(mm/dd/yy)to(yy/mm/dd)in a date column from a datagridview.It's possible to change settings in controlpanel>regional settings for each computer,but i want do that programmatically,i meant that whenever the user opens form,change automatically,thanks.
Posted

You should change your datagridview date column Default cell style
datagridview .Columns[0].DefaultCellStyle.Format = "yy/mm/dd";
 
Share this answer
 
v2
Comments
Henry Minute 25-Jan-11 21:24pm    
Good call!
Theingi Win 26-Jan-11 6:49am    
:)
maysam_p82 26-Jan-11 3:54am    
Thank you very much sir,you are great:**.my problem solved...
Theingi Win 26-Jan-11 6:49am    
Your welcome!
deepak_program 26-May-11 0:23am    
Thank you sir for your valuable information
Try Below:

DateTime d=DateTime.parse("01/25/2011");
d. ToString("yy/MM/dd");
 
Share this answer
 
v2
You cannot change the 'date format' of the column.

What you can do is handle the OnCellFormatting[^] event of your DataGridView.

What this event does is allow you to take the actual value contained by a cell and change what actually gets displayed. So if the value of a cell is 10 you can actually display "bananas", without breaking your application.

If you follow the link above, the code on that page shows how to format dates.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900