Purpose: When the date data for a record is empty, the DateTimePicker is not displayed at the default current time.
Advantages: Avoid irregular time format input, and meet the usual time input habits
Cons: Set to Code, no TextBox controls so easy to set up
Steps:
1. Insert Control DateTimePicker
2. In the A form ( target form ) Load event, or B form to open a form, fill in the following statement (I'm here to open a form with B form)
DimFrmsampleorder as Newfrmsampleorder frmsampleorder.show ()IfDatagridview1.rows (E.rowindex). Cells ("Scheduled ship Date"). Value.ToString.Trim ="" ThenFrmSampleOrder.txt planned date of shipment. Format=Datetimepickerformat.custom frmSampleOrder.txt planned date of shipment. CustomFormat=" " ElseFrmSampleOrder.txt planned date of shipment. Text= Datagridview1.rows (E.rowindex). Cells ("Scheduled ship Date"). Value.ToString.TrimEnd If
3. In the Open a form, select the DateTimePicker control and select the ValueChanged event to insert the following code
Private Sub as Object as Handles txt scheduled shipping date. valuechanged = datetimepickerformat.short End Sub
4, save.
This completes the usual habit of a date selection control
vb.net datetimepicker initialized to NULL, select to display the date