Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

C# 5 .NET 4.0 formating a time column in a DataGridView...

$
0
0

I have a bound DataGridView that has a time column that displays the time in 24 hour time format.  I would like it to display in a 12 hour formatand be editable in 12 hour format.  Of course, when and entry like 5:30 PM gets back to the db, it would become 17:30:00.

I have tried using:

 CompanyDataView.Columns["PriceChangeTime"].DefaultCellStyle.Format = "hh.mm s";

or

 CompanyDataView.Columns["PriceChangeTime"].DefaultCellStyle.Format = "hh.mm:ss";

or 

 CompanyDataView.Columns["PriceChangeTime"].DefaultCellStyle.Format = "h";

and a number of other variations of format strings I have found in posts, but they all throw errors when the column displays.



Newark IT Guy...


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>