MattDAVM
MattDAVM

Reputation: 515

DateTime to "Time" in a DataGridView

Good morning! I have a Form which has a DataGridView with a few time informations that I have to show it on a label. But as I can see, my label (and DataGrid) have Date and Time included (and I only need the time on my DataGrid and label).

I know visual studio c# doesn't has a style that converts DateTime only to "Time", but I don't know how to format these datas only as Time to show it on my label.

What should I do to: Format this DateTime only to show Time (on my DataGrid) and then appears only as Time on my label as well (this label retrieves the DataGrid information).

Upvotes: 0

Views: 2069

Answers (1)

DartAlex
DartAlex

Reputation: 264

Set DefaultCellStyle

dataGridView1.Columns["Column with time"].DefaultCellStyle.Format = "HH:mm:ss";

Upvotes: 3

Related Questions