Datetimepicker

G

Guest

Hey Folks

i wanted to ask about the datetimepicker.
I want a messagebox to appear as soon as the user clicks on the datetimepicker.
I have tried the valuechanged event but i want the message to appear way before this stage. I want to display it as soon as the calender is displayed or as soon as the mouse is pressed on the control.

I tried the click event but this didnt work. this is what i tried:

Private Sub dtpRoomDate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtpRoomDate.Click
If LViewMealBookings.Items.Count > 0 Then
MsgBox("Changing the room date will cause all your meal bookings to be lost. Do you wish to continue?", vbYesNo)
If vbYes Then
dsFullBooking.Tables("dtMealBooking").Clear()
LViewMealBookings.Items.Clear()
End If
End If

End Sub

Can anyone help me?
 
C

Cor

Hi Avni,

Try this
\\
If MsgBox("Changing the room date will cause all your meal bookings to be
lost. Do you wish to continue?", _
MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
//

I hope this helps?

Cor
 
G

Guest

Hello Cor

Thank u for the coding. What im confused on is what event to include this code under as i want the message to appear as soon as the user clicks on the dateTimePicker (i.e, before the calender appears). I have so far put this code on the valuechanged event, but i want this message to appear before the user gets the chance to change the date
If i have to include it in this valuechanged event, how do i ensure that if the user clicks 'NO' in the messagebox the date is not actually changed and is returned to its previous date

I tried including this code in the click event for the dtp but the messagebox never seemed to appear!!?
 
C

Cor

Hi Avni,

If you want not the user to select a date, why not give him a button on the
same place as the picker, after he has clicked it, you make the button
invissible and shows the picker.

Looks to me more friendly for the user, because that he can understand.

Or do I see something wrong?

Cor
Thank u for the coding. What im confused on is what event to include this
code under as i want the message to appear as soon as the user clicks on the
dateTimePicker (i.e, before the calender appears). I have so far put this
code on the valuechanged event, but i want this message to appear before the
user gets the chance to change the date.
If i have to include it in this valuechanged event, how do i ensure that
if the user clicks 'NO' in the messagebox the date is not actually changed
and is returned to its previous date?
 
G

Guest

Hi Cor

Do u know how i could revert the date back to its previous value if the user selects no in my messagebox
I have decided to use the valuechanged event
If the user selects yes then i want the date value to change toi whatever the user has selected. If they select no the old date is restored. Is this possible or not a good method
 
C

Cor

Hi Avni,

I nowhere have seen how you used the text from the datapicker.

There are so many posibilities, but they all depend on your program and I
think that is to big to investigate for me.

Cor
Do u know how i could revert the date back to its previous value if the
user selects no in my messagebox?
I have decided to use the valuechanged event.
If the user selects yes then i want the date value to change toi whatever
the user has selected. If they select no the old date is restored. Is this
possible or not a good method?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top