Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1082
BindingListIndex not works with Recurring Appointments...
posted

BindingListIndex not works with recurring appointments...

Hi,

I uploaded my appointments into a grid. To display the selected appointment I use the GetAppointmentFromBindingListIndex() function . Whenever I select a recurring appointment a null reference exception appears. How can I fix this?

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 );

      }

}

 

Parents
  • 69832
    Verified Answer
    Offline posted

    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.

Reply Children