I was wondering, how do I show a 24hr clock in a WPF datagrid? At the moment, the datagrid has set itself to 12 clock, using am & pm which is just plain confusing.
In the datagrid it has a simple column binding
…and I get the following
6/29/2010 10:46:42AM
6/29/2010 11:14:10PM
alt text http://picasaweb.google.com/lh/photo/NT6sM72khL10KZvoRPS9ww?feat=directlink
I’m not positive that I understand what you are asking, but I believe you just want to change the time format in your bound data?
That’s fairly easy – use StringFormat. For example:
txt12Hour shows something like 05:17:27 PM
txt24Hour shows something like 17:17:27
Use any of the same formatting rules that you’d use in a ToString() call in code. This applies not only to dates, but numbers, currencies, etc.