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 get a working demo. It would be highly appreciated . iqunas@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.
stokara,
I am very interested in this working example as well. I have been trying to use my own database and a custom appointment form and have not found too much help on line. Your post here looks exactly like what I am trying to do. Much appreciated if I could get a copy.
dwitsken@jcom.cc
Avi,
Your example is working great for me but I need to set the Ownersdatabinding to the calendarinfo as well, based on your exampledataset. I am not having any luck. Any insight would help immensely. My purpose is to be able to show the monthviewsingle as seperate calendars for each owner similar to the winschedule database demo.
Thank You
Dale
This is awesome! I have it working and it looks like it is exactly what I was looking for. Can't thank you enough. Was pulling my hair out on this one.
Thanks again!
I forgot to attatch the script to create the SQL Server tables.
Create a database called AppointmentExample and then run this script to create the tables with some sample data.
Avi
Here is an example I put together. I used a dataset with SQL Server as the data source but I'm sure t work as well with onother data source. Let me know how it goes.