I am trying to make it so when the user pushes a button, a DateTimePicker dialog gets shown, and I would even like to get the resulting date they picked. Here’s what I have so far:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Dis As System.Windows.Forms.DateTimePicker = New System.Windows.Forms.DateTimePicker()
' Set the MinDate and MaxDate.
Dis.MinDate = New DateTime(1985, 6, 20)
Dis.MaxDate = DateTime.Today
' Set the CustomFormat string.
Dis.CustomFormat = "MMMM dd, yyyy - dddd"
Dis.Format = Windows.Forms.DateTimePickerFormat.Custom
' Show the CheckBox and display the control as an up-down control.
Dis.ShowCheckBox = True
Dis.ShowUpDown = True
Dis.Show()
End Sub
But when I push the button and run the code, nothing gets displayed. I would think there ought to be a way to simply display this dialog programmatically. Can anyone help me please? 🙂
Just FYI, I’m coding this in VB 2010 if that helps any? :-\
What I wound up doing, is I made a button, which opens up a separate form, which I made to look like a dialog, and put a
DateTimePickeron. That was the best workaround I could figure out how to do.