I am starting to understand the options in the CalendarTimeChooser and making progress.
But something I can’t understand, and hope someone can educate me on this.
I used the sample in the docs to create a button class QS_PushButton
Next added an instance of the button class to my window and named it QS_PushButton1 ( super = QS_PushButton )
I wanted to be able to set specific options for each instance of the button, so did the following :
- moved the line :
CalTimeChooser = New DateTimeWindow
to the start of the Method : mSetOptions in the class
deleted the Action event from the QS_PushButton events in the class
dragged button class QS_PushButton to the window, created QS_PushButton1 ( Super = QS_PushButton )
added an Action event to the instance of the class ( QS_PushButton1 ) :
Sub Action() QS_PushButton1.mSetOptions // use the default options from the QS_PushButton class // now modify only the options that I want to change QS_PushButton1.CalTimeChooser.Cancel_Button.caption = "zz" QS_PushButton1.CalTimeChooser.VisiblePickers = Date_Time_Container.PickerElements_CalendarOnly QS_PushButton1.CalTimeChooser.Date_Time_Container1.Calendar_Container1.RecurringCanvas1.visible = false End Sub
At this point, everything is working perfectly.
I can change options in mSetOptions to affect all instances of the button, and change options in QS_PushButton1 Action Event to change options in the specific button’s chooser only.
Next I want to get the selected date from the Chooser.
So here’s what I did :
In the CLASS, changed the following :
in the Cancel_Button event, changed the code to :
Added a Public Property to the DateTimeWindow in the class :
GoDate As Date
In the Finished_Button event, changed the code to :
GoDate = SelectedDate me.window.Close
On my window, next to the QS_PushButton1, added a standard push button :
Sub Action() // this line will work and displays the Date stored in the GoDate property of the instance msgbox str(QS_PushButton1.CalTimeChooser.GoDate) // the following lines do not work - NilExceptionError msgbox str(QS_PushButton1.CalTimeChooser.SelectedDate) msgbox str(QS_PushButton1.CalTimeChooser.Date_Time_Container1.SelectedDate) End Sub
So on my window, Click on QS_PushButton1 causes the Action Event, sets the options, and displays the Chooser.
On the Chooser window, Click on the required Date, then Click on ‘Select’ to close the Chooser window.
When I then Click on PushButton1, the first MsgBox displays ( using the GoDate property of the class instance ) but the other lines ( using the SelectedDate property ) fail with NilExceptionError.