Wednesday, May 07, 2008

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

Search
Navigation
On this page....
Archives
<September 2008>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
Aggregate Me!
RSS 2.0 | Atom 1.0 | CDF
Categories
Blogroll
Contact me
Send mail to the author(s) E-mail
Themes
Administration