Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateTimePicker driving me crazy 1

Status
Not open for further replies.

jadepatel

Technical User
Sep 4, 2002
35
0
0
GB
Hi,

Does anyone know how i could override the datechange for a dateTimePicker (DTP) Control. i.e when the user selects a date from the dtp they click a save button and this value is then pushed into a varibale. The user can then make bookings for that date. If the user goes back and chooses to edit that date they click the edit date button which enables the DTP. When the user clicks on a new date i have a msgbox that appears informing the user that if they change the date their bookings will be lost.And if they wish to continue. If they choose yes the date changes to whatever they sleected before the msgbox appeared. However the problem i have is that if they click 'NO' the date is still changed. How do i overide it so that the date does not change to whatever was selected before the msgbox appeared??

Alternatively is there a event that is fired when the user clicks on the arrow of the DTP?? This way i can have the msgbox appear here instead of after the user changes the date.

Any advise would be greatly appreaciated.

thx in advance.
 
You can use Dropdown event to do this and if the user clicks "No" to your messagebox then you can send a key to datetimepicker to close it automatically. Here is the code to do this

Code:
Private Sub dtpTest_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtpTest.DropDown

If (MessageBox.Show("Do you want to continue?", "Test", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.No) Then

     dtpTest.Focus()
     SendKeys.Send("%{F4}")
End If
End Sub

Let me know if this works for you.

-Kris
 
Thanks so much for your help Kris.
This is exactly what i was looking for.
:eek:)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top