Format TimeSpan in DataGridView column

前端 未结 5 1509
梦毁少年i
梦毁少年i 2020-12-16 22:27

I\'ve seen these questions but both involve methods that aren\'t available in the CellStyle Format value. I only want to show the hours and minutes portion (16:05); not the

5条回答
  •  暖寄归人
    2020-12-16 23:17

    I don't know how to set the format of the cell to show only hours and minutes. I'd suggest you set the format of the cell to string and format the value like this:

    String.Format("{0:D2}:{1:D2}",
        DateTime.Now.TimeOfDay.Hours, DateTime.Now.TimeOfDay.Minutes);
    

提交回复
热议问题