Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using datagrid view in winform, and i am using the smalldatetime as datatype, but it is accepting the date as mm/dd/yyyy HH:MM:SS AM
how to save that in
dd/mm/yyyy HH:MM:SS AM format
Posted

1 solution

Check this similar thread
Date value in datagridview[^]
 
Share this answer
 
Comments
sariqkhan 18-Dec-12 2:51am    
the second ans
Thread.CurrentThread.CurrentCulture =
System.Globalization.CultureInfo.InvariantCulture;
dataGridView1.Columns("time7").DefaultCellStyle.Format =
"dd/MM/yyyy hh:mm tt";
it is showing the error at column
Non-invocable member 'System.Windows.Forms.DataGridView.Columns' cannot be used like a method
__TR__ 18-Dec-12 3:16am    
Try this
dataGridView1.DataSource = ds;
dataGridView1.Columns["your Column Index"].DefaultCellStyle.Format = "dd/MM/yyyy hh:mm:ss";
dataGridView1.DataBind();
sariqkhan 18-Dec-12 3:54am    
sir i am using c sharp what code you are providing?
two errors are there
The name 'ds' does not exist in the current context
'System.Windows.Forms.DataGridView' does not contain a definition for 'DataBind' and no extension method 'DataBind' accepting a first argument of type 'System.Windows.Forms.DataGridView' could be found (are you missing a using directive or an assembly reference?
__TR__ 18-Dec-12 4:01am    
Ds is your datasource. Change it to point to your data-source variable.
You can get rid of the dataGridView1.DataBind() line as this is a winform. did not notice that.
sariqkhan 18-Dec-12 4:23am    
i dont know about datasource variable what is that?

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