Thanks for the help.
Regards, Lello
_______________________________________
STEP TO REPRODUCE:
// STEP 1
private DataTable CreateTableAppointmentsInRange()
{
DataTable newTable = new DataTable("AppointmentData");
newTable.Columns.Add("Subject", typeof(string));
newTable.Columns.Add("StartDateTime", typeof(DateTime));
newTable.Columns.Add("EndDateTime", typeof(DateTime));
newTable.Columns.Add("Description", typeof(string));
newTable.Columns.Add("Location", typeof(string));
newTable.Columns.Add("OwnerKey", typeof(string));
newTable.Columns.Add("AllDayEvent", typeof(bool));
newTable.Columns.Add("Locked", typeof(bool));
newTable.Columns.Add("Visible", typeof(bool));
newTable.Columns.Add("IsRecurringAppointmentRoot", typeof(bool));
newTable.Columns.Add("HasReminder", typeof(bool));
newTable.Columns.Add("BarColor", typeof(Color));
newTable.Columns.Add("BindingListIndex", typeof(int));
foreach ( DateRange oRange in this.CalendarInfo1.AlternateSelectedDateRanges )
foreach (Infragistics.Win.UltraWinSchedule.Day oDay in oRange.Days)
for (int i = 0; i < oDay.Appointments.Count; i++)
// Create an object array, populated with the appointment
// properties of interest.
object[] appointmentData = new object[]
oDay.Appointments[i].Subject,
oDay.Appointments[i].StartDateTime,
oDay.Appointments[i].EndDateTime,
oDay.Appointments[i].Description,
oDay.Appointments[i].Location,
oDay.Appointments[i].OwnerKey,
oDay.Appointments[i].AllDayEvent,
oDay.Appointments[i].Locked,
oDay.Appointments[i].Visible,
oDay.Appointments[i].IsRecurringAppointmentRoot,
oDay.Appointments[i].HasReminder,
oDay.Appointments[i].BarColor,
oDay.Appointments[i].BindingListIndex,
};
// Add a row to the new table to represent this Appointment.
newTable.Rows.Add(appointmentData);
}
return newTable;
// STEP 2
DataTable AppointmentsTable = CreateTableAppointmentsInRange();
this.Grid1.SetDataBinding(AppointmentsTable, string.Empty);
// STEP 3
private void Grid1_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
if (e.Cell.Row.Cells["BindingListIndex"].Value != null)
//Display the Selected Appointment dialog to edit the appointment
int BindingListIndex = Convert.ToInt32(e.Cell.Row.Cells["BindingListIndex"].Value);
// Whenever I select a recurring appointment
// a null reference exception appears. How can I fix this?
Appointment app = this.CalendarInfo1.Appointments.GetAppointmentFromBindingListIndex(BindingListIndex);
this.CalendarInfo1.DisplayAppointmentDialog( app );
I wasn't able to track down the reason for a null ref exception, but an unmodified member of a recurrence will return -1 from its BindingListIndex property, because it does not belong to the underlying data source. If you want to refer to the list object with which it is associated (the recurring appointment root's list object), get a reference to that appointment via the RecurringAppointmentRoot property, then access that appointment's BindingListIndex.
OK Brian, So it works.
Thanks for the reply!
int myBindingListIndex = oDay.Appointments[i].BindingListIndex;
if (oDay.Appointments[i].RecurringAppointmentRoot != null)
myBindingListIndex = oDay.Appointments[i].RecurringAppointmentRoot.BindingListIndex;
myBindingListIndex
//Initialize
Appointment selectedAppointment =
this.ultraCalendarInfo1.Appointments.GetAppointmentFromBindingListIndex(BindingListIndex);
// So it works….
this.ultraCalendarInfo1.DisplayAppointmentDialog(selectedAppointment);