[Gambas-user] how to set a specific day in datechooser component

Tobias Boege taboege at ...626...
Fri Jan 31 18:13:50 CET 2014


On Fri, 31 Jan 2014, PICCORO McKAY Lenz wrote:
> There's some way to select  specific date and limits choose to this day in
> the datechoose calendar component?
> 
> i mean...  limits the dais to choose to only future dais!
> 

You have to do that yourself (let dtcDate be your DateChooser):

Public Sub dtcDate_Change()
  dtcDate.Value = Max(Now(), dtcDate.Value)
End

Alas, the DateChooser does not support Stop Event in the Change event, so
I always reset the dtcDate.Value to Now() when the user chose a past date.

If you want to reset the date to what the user had chosen before, you must
save that value after each succeeding dtcDate_Change() and change the event
handler in the obvious ways...

(Maybe the above code works because of a bug: it's generally dangerous to
change the value of something during its Change event. To be future-proof
you would wrap the line above into Object.Lock(Last) and Object.Unlock(Last)
lines. Benoit?)

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list