DataTablet, Datagrid, and DateTime

  • Thread starter Thread starter Marco Martin
  • Start date Start date
M

Marco Martin

Hi all,

I've got a DataTable that has a datetime column that is bound to a datagrid.
The Datetime Column holds both Date *and* time, but my Datagrid only shows
the date. How would I go about getting it to display both Date *and* time?

regards,

Marco
 
Hi Marco,

1. Configure the grid with a programmatically created DataGridTableStyle
pre-populated with DataGridColumnStyle instances (see the
"DataGridTableStyle Class" topic in MSDN for detailed information).
2. Set the Format property on the corresponding DataGridColumnStyle to the
appropriate value (most likely "f", "F", "g" or "G"). See the "Standard
DateTime Format Strings" topic in MSDN for more information.
 
Thanks,

Much appreciated.

Marco
Dmitriy Lapshin said:
Hi Marco,

1. Configure the grid with a programmatically created DataGridTableStyle
pre-populated with DataGridColumnStyle instances (see the
"DataGridTableStyle Class" topic in MSDN for detailed information).
2. Set the Format property on the corresponding DataGridColumnStyle to the
appropriate value (most likely "f", "F", "g" or "G"). See the "Standard
DateTime Format Strings" topic in MSDN for more information.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Marco Martin said:
Hi all,

I've got a DataTable that has a datetime column that is bound to a datagrid.
The Datetime Column holds both Date *and* time, but my Datagrid only shows
the date. How would I go about getting it to display both Date *and* time?

regards,

Marco
 
Back
Top