Thank you for your reply adata, but I don't think that small code solves my problem.

http://img28.imageshack.us/img28/9484/68091436.png

^ On the right side of the DateTimePicker is a updown button called UpDown(labeled on the properties).

I want my program to add or subtract 30 minutes every click on the UpDown(if the minute is selected beforehand). The default is 1min for add/subtract.


Does any one knows how to capture the event when up or down is clicked on the time picker?.

I've tried searching it, so please stop with -1 already.

Edited 7 Years Ago by yorro: n/a

Attachments 68091436.png 1.02 KB

Here's how I did this, only difference is I was going by 15 minute increments rather than 30.

Private Sub DateTimePicker1_ValueChanged(sender As Object, e As System.EventArgs) Handles DateTimePicker1.ValueChanged
    Select Case DateTimePicker1.Value.Minute
        Case 1, 16, 31, 46
            DateTimePicker1.Value = DateTimePicker1.Value.AddMinutes(14)
        Case 14, 29, 44
            DateTimePicker1.Value = DateTimePicker1.Value.AddMinutes(-14)
        Case 59
            DateTimePicker1.Value = DateTimePicker1.Value.AddMinutes(-74)
    End Select
End Sub

Hi,

You can try this:

 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        DateTimePicker1.Format = DateTimePickerFormat.Time

    End Sub

    Private Sub DateTimePicker1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles DateTimePicker1.KeyDown
        If e.KeyValue = 38 Then ' Arrowkey Up
            ' up
            DateTimePicker1.Value = DateTimePicker1.Value.AddMinutes(30)
            e.SuppressKeyPress = True
        ElseIf e.KeyValue = 40 Then ' ArrowKey Down
            'down
            DateTimePicker1.Value = DateTimePicker1.Value.AddMinutes(-30)
            e.SuppressKeyPress = True
        End If
    End Sub

Change Minutes with the Arrowkeys Up and Down.

This article has been dead for over six months. Start a new discussion instead.