To leverage the DatePicker control just drag it on the form. Then in the form load function determine the format (e.g., DateTimePicker1.Format = DateTimePickerFormat.Short ). The selected date is then available in the Text property of the control (and should show up on the form). By default today's date should be shown.
The key properties for the calendar are
SelectionStart - This is the first selected date (it is possible to select multiple dates at a time!)
TodayDate - This sets today's date (which otherwise is set automatically by the system clock!)
Enumerations are commonly used for small sets of finite values (i.e., types or status). It is easy to work with Enums in the .NET framework, the .NET compact framework, however, has some limitations. The example below is for an Enum called PersonStatus (with the values Here, There, Somewhere)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' In the .NET framework this would work
' Me.ComboBox1.DataSource = [Enum].GetNames(GetType(PersonStatus))
' Unfortunately this does not work in the .NET Compact Framework
' So some hardcoding needs to be done ...
Me.ComboBox1.Items.Add("Here")
Me.ComboBox1.Items.Add("There")
Me.ComboBox1.Items.Add("Somewhere")
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case Me.ComboBox1.SelectedItem
Case "Here"
thisPerson.Status = PersonStatus.Here
Case "There"
thisPerson.Status = PersonStatus.There
Case "Somewhere"
thisPerson.Status = PersonStatus.Somewhere
Case Else
'do nothing
End Select
End Sub
Powered by Zoundry