C# DataGridView date time formatting of a column

前端 未结 2 613
长情又很酷
长情又很酷 2021-01-20 19:16

I have datagridview which fills data from database, there are columns where I have date and time in them \"MMddyyyy\" and \"hhmmss\" format, what I want to do is when the da

2条回答
  •  梦毁少年i
    2021-01-20 19:36

    The sintax in DataGridView formating is a little different then in DateTime, but you can get the same result. In my example i have a Time collumn, that by default shows HH:mm:ss and I want to show only hours and minutes:

     yourDataGridView.Columns["Time"].DefaultCellStyle.Format = @"hh\:mm";
    

提交回复
热议问题