i'm trying to add keywords to the ultracalendarcombo box to expedite entry of data. The keywords are "Today", Tomorrow, and yesterday. so the user types today and preses tab or enter and the ultracalendarcombo enters 4/22/2009 automatically. I have this working perfectly under the ValidationError functionality when I type today and press tab however when I type today and press enter this code does not fire. Is there a fundimental problem with my logic?
Private Sub ProductiveComboCalendar_ValidationError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.DateValidationErrorEventArgs) Handles Me.ValidationError
If Me.Text.ToUpper = "TODAY" Then
e.NewValue = CDate(Now)
OnValueChanged(e) '<-- the new value hasn't applied yet, so this doesn't
ElseIf Me.Text.ToUpper = "TOMORROW" Then
e.NewValue = CDate(DateAdd("d", 1, Now))
OnValueChanged(e) '<-- the new value hasn't applied yet, so this doesn't work
ElseIf Me.Text.ToUpper = "YESTERDAY" Then
e.NewValue = CDate(DateAdd("d", -1, Now))
End If
End sub
SendKeys.Send posts the message asynchronously, whereas SendKeys.SendWait will send it immediately and wait until it has completed. That might be the reason it doesn't work. I am also jnot clear on how VB handles these things, that might have something to do with it.
You should be able to add a key mapping to navigate to the next control ijn the tab order when Enter is pressed:
Dim keyMapping As New Infragistics.Win.UltraWinSchedule.CalendarCombo.KeyActionMapping(Keys.Enter, CalendarCombo.CalendarComboAction.NextControl, 0, 0, 0, 0)Me.ultraCalendarCombo1.KeyActionMappings.Add(keyMapping)
ok, excellent, that makes sense.
One more thing then. I want the enter button to behave like the tab button. I put this code in and it does execute however the focus does not leave the calendar control.
Private Sub ProductiveComboCalendar_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If e.KeyChar = Microsoft.VisualBasic.Chr(13) Then
SendKeys.Send(vbTab)
End Sub
The event only fires when the user leaves the control.