Hello,
I am programming a scheduling application and I am running into a problem when first changing dates to pull appointments on an ultramonthmulti control and a UltracheckEditor. What I am doing is selecting a date from my calendar control and it will get appointments seven days before the selected date and 7 days after. It will then match the schedules to the owners. that part works fine. However, when I uncheck an owner so their column on the dayview won't show, I get the error "Cannoe access a disposed object."
Here is the code I'm using where the error occurs:
#region Owner Checkbox Actions
private void OwnerCheckbox_CheckedChanged(object sender, EventArgs e)
{
UltraCheckEditor checkEditor = sender as UltraCheckEditor;
Owner owner = checkEditor.Tag as Owner; //<-- this is causing the Owner to be Disposed!!!
MessageBox.Show(owner.Disposed.ToString());
owner.Visible = checkEditor.Checked;
}
I am basing this code on the sample SCHEDULE CS Demo that is provided. Now, if I do not change the date on the calendar control (as I load the schedule data as well as the owners at the Form_Load event), I can successfully check and uncheck owners. It properly hides and unhides the owner's schedule column in the dayview and the owner's row in the timelineview. The "dispose" error only occurs after I change to another date on the multi calendar (which is connected to a calendarInfo). The code to fetch schedules and plot them based on the date selected is performed in a MouseUp event. All I am doing in this even is binding data based on the selected date.
Any ideas why this is happening?
Hi,
The problem was that I was re-binding the Owners table when I did not have to during databinding.