I am trying to clear the appointments for the current month in DayViewControl but it seems that i can't do it. I am able to clear the appointments for active day using
UltraCalendarInfo.ActiveDay.Appointments.Clear()
Is there any possible way to clear the appointments for current/active month?
Thanks,
You should not have to remove Owners or Appointments in order to reflect changes made to the Appointment.Appearance properties (I am assuming that is how you are changing the color). I don't recall any problems like the one you describe here with NetAdvantage 2007.1, but that version is no longer supported so if there is it would not be addressed in that version. You can try the following before calling UltraDayView.Refresh:
UIElement controlElement = this.dayView.UIElement;if ( controlElement != null ) controlElement.DirtyChildElements( true );
I that doesn't clear up the problem, you can repost but I think we will need more details, specifically clarification on exactly how you are changing the color of the appointments. Here is an example of the code I used to verify that this is working correctly in the latest version:
this.calendarInfo.BeforeDisplayAppointmentDialog += new DisplayAppointmentDialogEventHandler(calendarInfo_BeforeDisplayAppointmentDialog);
private void calendarInfo_BeforeDisplayAppointmentDialog(object sender, DisplayAppointmentDialogEventArgs e){ e.Cancel = true;
ColorDialog colorDialog = new ColorDialog(); if( colorDialog.ShowDialog(this) == DialogResult.OK ) e.Appointment.Appearance.BackColor = colorDialog.Color;}
I have a problem with Ultradayview.
I have appointments displayed on the Ultradayview. I allow the user to configure the appointment with a dialog box where they select the color for the appointment. After the user closes the dialog box, I need to redraw the current day, because the appointment color may have changed.
I am attempting to redraw the Ultradayview by the following logic:
1) Remove all Appointments
2) Remove all Owners
3) Re-add all Owners
4) Re-add all Appointments
When I do this series of steps, the Ultradayview still displays the old Appointments with the old colors, even though I have cleared all the Appointments and Owners and re-added them! There appears to be a caching mechanism I'm running up against.
The specific steps in the code that I call when I want to redraw are:
calendarInfo.ActiveDay = calendarInfo.GetDay(CurrentDate, true); // CurrentDate is "today", and it is the same day that was already showing on the UltraDayView
calendarInfo.Owners.Clear();
(in a loop)
calendarInfo.Owners.Add(...);
(end loop)
calendarInfo.Appointments.Clear();
calendarInfo.Appointments.Add(...); // the appointments are re-added with different colors here
So, after I do this, it appears to do "nothing". If I manually change days to another day, then come back to the current day, then the Appointments correctly draw in the udpated colors. So something is "totally" clearing out the Appointments when I switch days. I want to "totally" clear out the appointments manually instead of having to switch days to get the Appointments to redraw.
I am using Infragistics version 7.1 library in C#. Thanks in advance for any help you can provide.
Some other approaches I have tried, that don't work, are:
GetAppointmentsInRange(StartDate, EndDate).Clear();
calendarInfo.Reset();
calendarInfo.ResetActiveDay();
UltraDayView.Refresh();
Thankls Brian--
I have solved my probelm by calling following method of UltracalendarInfo.
GetAppointmentsInRange(StartDate, EndDate).Clear()
Without additional details it is difficult to speculate about what might be causing the problem, but one possibility is that the ActiveDay is not referencing the date you think it is. UltraDayView displays the contents of the UltraCalendarInfo.SelectedDateRanges collection, which does not necessarily contain the ActiveDay.