Being new the library I was disappointed to see the main recommendation for storing additional appointment data is to stuff the data into the tag. While functional, this is far from elegant and I would really like to see the ability to extend the Appointment class via inheritance.
In the mean time I am using a different approach which does not use the tag and enables me to store and retrieve additional appointment data. By sharing the BindingSource from the UltraCalendarInfo to my custom Appointment form I am able to bind the controls so that they edit all the columns, both the standard ones like StartTime and EndTime as well as my custom fields. My database contains only the columns I want and not the duplicated binary versions of the customer data in the tag/AllProperties field as has been suggested.
There are two scenarios to deal with Editing an existing appointment and adding a new one. Both call the custom form but there are some differences in terms of getting the BindingSource positioned correctly. On my custom appointment form I created a constructor which takes a parameter of type BindingSource and pass the AppointmentBindingSource to the form:
Dim AppointmentDialog As myCustomAppointmentForm = New myCustomAppointmentForm(UltraCalendarInfo1.DataBindingsForAppointments.DataSource)
In the form load of the customer Appointment form, this binding source is used to bind the all the controls and edit all the columns including my customer fields. For example:
Me.SubjectTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text",_ AppointmentBindingSource, "Subject", True))
I handle the BindingComplete event to ensure the BindingSource remains synchronized between the two forms:
Private Sub AppointmentBindingSource_BindingComplete( ByVal sender As Object, _
ByVal e As BindingCompleteEventArgs) _
Handles AppointmentBindingSource.BindingComplete
If e.BindingCompleteContext = BindingCompleteContext.DataSourceUpdate _
AndAlso e.Exception Is Nothing Then
e.Binding.BindingManagerBase.EndCurrentEdit()
End If
End Sub
Finally, right before calling the custom Appointment form in the BeforeDisplayAppointmentDialog event I force the Bindingsource to reposition to the appointment record being edited:
AppointmentBindingSource.Position = e.Appointment.BindingListIndex
To be able to deal with a new appointment, the appointment needs to be created and added to appointment needs to be created and added to the UltraCalendarInfo1.Appointments collection. This will perform the BindingSource.addnew that we need.
If e.IsExistingAppointment Then
Me.UltraCalendarInfo1.Appointments.Add(e.appointment)
On the return from the custom Appointment form (which I call as a dialog) if the user pressed Cancel then we need to get rid of the appointment we just added:
Dim dResult As DialogResult = AppointmentDialog.ShowDialog()
If dResult = DialogResult.OK Then
AppointmentTableAdapter.Update(Me.HousecallDataSet.appointment)
Else
AppointmentBindingSource.CancelEdit()
Me.UltraCalendarInfo1.Appointments.Remove(appt)
Hi Stokara , Can I have too a working demo. if u could done. i will allways be grateful with u.
many thanks
my email : jroldank@gmail.com
The code I have is a very complicated project.
I'm very busy right now but I'll try to get you one as soon as I can.
Hi stokara , Can I get a working demo. It would be highly appreciated . iqunas@gmail.com