如何将datetimepicker更改为仅在visual basic中显示时间?我在access和vb之间使用数据绑定源。在我的数据库中,时间显示为早上7:30,但在visual basic中的datetimepicker中,显示该字段的日期。
Private Sub TimeDateTimePicker_ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TimeDateTimePicker.ValueChanged
TimeDateTimePicker.Format = DateTimePickerFormat.Time
TimeDateTimePicker.ShowUpDown = True
DateTimePicker.value = DateTime.Now.ToString("HH:mmtt")
End Sub
答案 0 :(得分:1)
试试这个......
DateTimePicker.Format = DateTimePickerFormat.Time
DateTimePicker.ShowUpDown = True
或者......
DateTimePickerFormat.Custom
DateTimePicker.CustomFormat = "HH:mmtt"
DateTimePicker.ShowUpDown = True
设定时间......或查看this发布...
DateTimePicker.value = DateTime.Now.ToString("HH:mmtt") 'THIS WORKS SEE IMAGE BELOW