B4J Question [SOLVED] Where can I find a DatePicker example to review?

Mikelgiles

Active Member
Licensed User
Longtime User
I need to implement a DatePicker to use in a desktop app and am only finding sample code for web apps. I have been looking to find out what events I can use to update a B4XTable cell when a date is selected in the datepicker.
 

Mikelgiles

Active Member
Licensed User
Longtime User
I had used the designer and added view datepicker but found no event that was triggered because I didnt click all of the proper check boxes. Now that I have that fixed I have it working with the exception of not finding any way to set the default date to the date that was in the column/row that was clicked. Now I am wondering if I should have used AnotherDatepicker instead. I chose datepicker because it was the one that shows up in the designer(and AnotherDatepicker looked to be a overkill and complicated). Is datepicker a bad choice?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is nothing bad with the internal DatePicker however XUI Views date picker is simple to use:

B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private Dialog As B4XDialog
   Private DateTemplate As B4XDateTemplate
   Private xui As XUI
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.Show
   Dialog.Initialize(MainForm.RootPane)
   DateTemplate.Initialize
   Dialog.Title = "Example"
End Sub

Sub MainForm_MouseClicked (EventData As MouseEvent)
   Wait For (Dialog.ShowTemplate(DateTemplate, "", "", "Cancel")) Complete (Result As Int)
   If Result = xui.DialogResponse_Positive Then
       Log($"Selected date: $Date{DateTemplate.Date}"$)
   End If
End Sub
 
Upvote 0

Mikelgiles

Active Member
Licensed User
Longtime User
Thanks Erel, that works much better than what I was doing with the original datepicker and works like a charm. I was ignoring it because it looked so confusing but your examole made it pretty easy. Thanks again.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…